aboutsummaryrefslogtreecommitdiffstats
path: root/library/RTP_CodecPort.ttcn
blob: b94ae73edd704a8ec58770586daa1204e20195a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
module RTP_CodecPort {

/* Simple RTP Codec Port, translating between raw UDP primitives with
 * octetstring payload towards the IPL4asp provider, and RTP primitives
 * which carry the decoded abstract RTP data types as payload.
 *
 * (C) 2017 by Harald Welte <laforge@gnumonks.org>
 * All rights reserved.
 *
 * Released under the terms of GNU General Public License, Version 2 or
 * (at your option) any later version.
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

	import from IPL4asp_PortType all;
	import from IPL4asp_Types all;
	import from RTP_Types all;

	type record RTP_RecvFrom {
		ConnectionId		connId,
		HostName		remName,
		PortNumber		remPort,
		HostName		locName,
		PortNumber		locPort,
		RTP_messages_union	msg
	};

	template RTP_RecvFrom t_RTP_RecvFrom(template RTP_messages_union msg) := {
		connId := ?,
		remName := ?,
		remPort := ?,
		locName := ?,
		locPort := ?,
		msg := msg
	}

	type record RTP_Send {
		ConnectionId		connId,
		RTP_messages_union	msg
	}

	template RTP_Send t_RTP_Send(template ConnectionId connId, template RTP_messages_union msg) := {
		connId := connId,
		msg := msg
	}

	private function IPL4_to_RTP_RecvFrom(in ASP_RecvFrom pin, out RTP_RecvFrom pout) {
		pout.connId := pin.connId;
		pout.remName := pin.remName;
		pout.remPort := pin.remPort;
		pout.locName := pin.locName;
		pout.locPort := pin.locPort;
		pout.msg := f_RTP_dec(pin.msg)
	} with { extension "prototype(fast)" };

	private function RTP_to_IPL4_Send(in RTP_Send pin, out ASP_Send pout) {
		pout.connId := pin.connId;
		pout.proto := { udp := {} };
		pout.msg := f_RTP_enc(pin.msg);
	} with { extension "prototype(fast)" };

	type port RTP_CODEC_PT message {
		out	RTP_Send;
		in	RTP_RecvFrom,
			ASP_ConnId_ReadyToRelease,
			ASP_Event;
	} with { extension "user IPL4asp_PT
		out(RTP_Send -> ASP_Send:function(RTP_to_IPL4_Send))
		in(ASP_RecvFrom -> RTP_RecvFrom: function(IPL4_to_RTP_RecvFrom);
		   ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple;
		   ASP_Event -> ASP_Event: simple)"
	}
}