summaryrefslogtreecommitdiffstats
path: root/tinySDP/test/test_soa.h
blob: 0e1a333dce9135f0d097862acd07772bc8cd6800 (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
*	
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*	
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*	
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
*/
#ifndef _TEST_SOA_H
#define _TEST_SOA_H

#define SDP \
	"v=0\r\n" \
	"o=carol 28908764872 28908764872 IN IP4 100.3.6.6\r\n" \
	"s=-\r\n" \
	"t=0 0\r\n" \
	"c=IN IP4 192.0.2.4\r\n" \
	"m=video 0 RTP/AVP 31 34\r\n" \
	"a=rtpmap:31 H261/90000\r\n" \
	"a=rtpmap:34 H263/90000\r\n"


void test_create_sdp()
{
	tsdp_ctx_handle_t* ctx = TSDP_CTX_CREATE();
	const tsdp_message_t* sdp;
	char* str;
	
	// Create local SDP from string
	tsdp_ctx_local_create_sdp_2(ctx, SDP, strlen(SDP));
	if((sdp = tsdp_ctx_local_get_sdp(ctx))){
		if((str = tsdp_message_tostring(sdp))){
			TSK_DEBUG_INFO("Local SDP (2)=\n%s", str);
			TSK_FREE(str);
		}
	}
	
	// Create local SDP from object
	tsdp_ctx_local_create_sdp(ctx, sdp);
	if((sdp = tsdp_ctx_local_get_sdp(ctx))){
		if((str = tsdp_message_tostring(sdp))){
			TSK_DEBUG_INFO("Local SDP (1)=\n%s", str);
			TSK_FREE(str);
		}
	}

	// Add media to the local sdp
	tsdp_ctx_local_add_media_2(ctx, "audio", 0, "RTP/AVP",
			TSDP_HEADER_I_VA_ARGS("this is the (audio)information line"),
			
			// PCMU
			TSDP_FMT_VA_ARGS("0"),
			TSDP_HEADER_A_VA_ARGS("rtpmap", "0 PCMU/8000"),

			// 1016
			TSDP_FMT_VA_ARGS("1"),
			TSDP_HEADER_A_VA_ARGS("rtpmap", "1 1016/8000"),

			// GSM
			TSDP_FMT_VA_ARGS("3"),
			TSDP_HEADER_A_VA_ARGS("rtpmap", "3 GSM/8000"),

			tsk_null);
	if((str = tsdp_message_tostring(sdp))){
			TSK_DEBUG_INFO("Local SDP (audio)=\n%s", str);
			TSK_FREE(str);
		}

	// Add headers to the local sdp
	tsdp_ctx_local_add_headers(ctx,
			TSDP_HEADER_E_VA_ARGS("j.doe@example.com (Jane Doe)"),
			TSDP_HEADER_P_VA_ARGS("+44 (123)456789"),

			tsk_null);
	if((str = tsdp_message_tostring(sdp))){
			TSK_DEBUG_INFO("Local SDP (headers)=\n%s", str);
			TSK_FREE(str);
		}
	

	TSK_OBJECT_SAFE_FREE(ctx);
}

void test_soa()
{
	test_create_sdp();
}









#endif /* _TEST_SOA_H */
OpenPOWER on IntegriCloud