summaryrefslogtreecommitdiff
path: root/tools/sdp.h
blob: 14cb7e6c1a81dced6c5612d477eccfc1eb99f7a6 (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
/*
 * sdp.h: RFC2974 Session Description Protocol (SDP)
 *
 * See the main source file 'xineliboutput.c' for copyright information and
 * how to reach the author.
 *
 * $Id: sdp.h,v 1.3 2008-11-14 22:44:34 phintuka Exp $
 *
 */

#ifndef XINELIBOUTPUT_SDP_H_
#define XINELIBOUTPUT_SDP_H_


#define SDP_MIME_TYPE  "application/sdp"


static const char *vdr_sdp_description(const char *vdr_ip, 
				       int vdr_svdrp_port,
				       int vdr_xineliboutput_port,
				       const char *rtp_ip,
				       uint32_t rtp_ssrc,
				       int rtp_port, 
				       int rtp_ttl)
{
  static uint8_t s_serial = 0;
  static cString s_data;
  static char    s_hostname[257] = {0};

  uint64_t serial = (time(NULL) << 2) + ((s_serial++) & 0x03);

  if(!s_hostname[0])
    gethostname(s_hostname, 256);

  s_data = cString::sprintf(
	   /*** session ***/
	   /* version    */        "v=0"
	   /* origin     */ "\r\n" "o=%s %u %"PRIu64" IN IP4 %s"
	   /* name       */ "\r\n" "s=%s@%s (multicast %s:%d)"
	   /* opt:info   */ /*"\r\n" "i=vdr-xineliboutput primary device output"*/
	   /* time       */ "\r\n" "t=0 0"

	   /*** data stream(s) ***/
	   /* connection */ "\r\n" "c=IN IP4 %s/%d"
	   /*            */ "\r\n" "a=recvonly"
	   /*            */ "\r\n" "a=type:broadcast"
	   /*            */ "\r\n" "a=x-plgroup:vdr"
	   /* media      */ "\r\n" "m=video %d RTP/AVP 96"
	   /*            */ "\r\n" "a=rtpmap:96 MP2P/90000"
	   /* media      */ /*"\r\n" "m=video %d udp MP2P"*/
	   /*            */ /*"\r\n" "a=mux:ps"*/
	   /*            */ /*"\r\n" "a=packetformat:RAW"*/
#if 0
	   /*** rtsp control port ***/
	   /* connection */ "\r\n" "c=IN IP4 %s"
	   /* media      */ "\r\n" "m=control %d tcp/http rtsp"
#endif
	   /*** xineliboutput control port ***/
	   /* connection */ "\r\n" "c=IN IP4 %s"
	   /* media      */ "\r\n" "m=control %d tcp x-vdr-xineliboutput"

	   /*** SVDRP control port ***/
	   /* connection */ "\r\n" "c=IN IP4 %s"
	   /* media      */ "\r\n" "m=control %d tcp x-svdrp"

	   /* origin */
	   , "vdr", rtp_ssrc, serial, vdr_ip

	   /* name */ 
	   , "vdr", s_hostname, rtp_ip, rtp_port

	   /* video/mp2p udp/rtp */
	   , rtp_ip, rtp_ttl
	   , rtp_port
#if 0
	   /* tcp/http control/rtsp */
	   , vdr_ip
	   , vdr_xineliboutput_port
#endif
	   /* tcp control/x-vdr-xineliboutput */
	   , vdr_ip
	   , vdr_xineliboutput_port

	   /* tcp control/x-svdrp */
	   , vdr_ip
	   , vdr_svdrp_port
			    );
  return s_data;
}


#endif  /* XINELIBOUTPUT_SDP_H_ */