Changeset 08cb8e62e928457d00602f9b96cb8c4755a74305
- Timestamp:
- 10/02/07 09:50:47
(2 years ago)
- Author:
- Rémi Denis-Courmont <rem@videolan.org>
- git-committer:
- Rémi Denis-Courmont <rem@videolan.org> 1171097447 +0000
- git-parent:
[2f9e4e4c1287a4fd7b92c244332c35c33ad28fc8]
- git-author:
- Rémi Denis-Courmont <rem@videolan.org> 1171097447 +0000
- Message:
Add support for session description
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rcaf669c |
r08cb8e6 |
|
| 22 | 22 | *****************************************************************************/ |
|---|
| 23 | 23 | |
|---|
| 24 | | # include <vlc/vlc.h> |
|---|
| | 24 | #include <vlc/vlc.h> |
|---|
| 25 | 25 | |
|---|
| 26 | | # include <string.h> |
|---|
| 27 | | # include <vlc_network.h> |
|---|
| 28 | | # include <vlc_charset.h> |
|---|
| | 26 | #include <string.h> |
|---|
| | 27 | #include <vlc_network.h> |
|---|
| | 28 | #include <vlc_charset.h> |
|---|
| 29 | 29 | |
|---|
| 30 | | # include "stream_output.h" |
|---|
| | 30 | #include "stream_output.h" |
|---|
| 31 | 31 | |
|---|
| 32 | | # define MAXSDPADDRESS 47 |
|---|
| | 32 | #define MAXSDPADDRESS 47 |
|---|
| 33 | 33 | |
|---|
| 34 | 34 | static |
|---|
| … | … | |
| 69 | 69 | |
|---|
| 70 | 70 | |
|---|
| 71 | | char *StartSDP (const char *name, |
|---|
| | 71 | static vlc_bool_t IsSDPString (const char *str) |
|---|
| | 72 | { |
|---|
| | 73 | if (strchr (str, '\r') != NULL) |
|---|
| | 74 | return VLC_FALSE; |
|---|
| | 75 | if (strchr (str, '\n') != NULL) |
|---|
| | 76 | return VLC_FALSE; |
|---|
| | 77 | if (!IsUTF8 (str)) |
|---|
| | 78 | return VLC_FALSE; |
|---|
| | 79 | return VLC_TRUE; |
|---|
| | 80 | } |
|---|
| | 81 | |
|---|
| | 82 | |
|---|
| | 83 | char *StartSDP (const char *name, const char *description, const char *url, |
|---|
| | 84 | const char *email, const char *phone, |
|---|
| 72 | 85 | const struct sockaddr *orig, socklen_t origlen, |
|---|
| 73 | 86 | const struct sockaddr *addr, socklen_t addrlen) |
|---|
| … | … | |
| 75 | 88 | uint64_t t = NTPtime64 (); |
|---|
| 76 | 89 | char *sdp, machine[MAXSDPADDRESS], conn[MAXSDPADDRESS]; |
|---|
| | 90 | const char *preurl = "\r\nu=", *premail = "\r\ne=", *prephone = "\r\np="; |
|---|
| 77 | 91 | |
|---|
| 78 | | if (strchr (name, '\r') || strchr (name, '\n') || !IsUTF8 (name) |
|---|
| | 92 | if (name == NULL) |
|---|
| | 93 | name = "Unnamed"; |
|---|
| | 94 | if (description == NULL) |
|---|
| | 95 | description = "N/A"; |
|---|
| | 96 | if (url == NULL) |
|---|
| | 97 | preurl = url = ""; |
|---|
| | 98 | if (email == NULL) |
|---|
| | 99 | premail = email = ""; |
|---|
| | 100 | if (phone == NULL) |
|---|
| | 101 | prephone = phone = ""; |
|---|
| | 102 | |
|---|
| | 103 | if (!IsSDPString (name) || !IsSDPString (description) |
|---|
| | 104 | || !IsSDPString (url) || !IsSDPString (email) || !IsSDPString (phone) |
|---|
| 79 | 105 | || (AddressToSDP ((struct sockaddr *)&orig, origlen, machine) == NULL) |
|---|
| 80 | 106 | || (AddressToSDP ((struct sockaddr *)&addr, addrlen, conn) == NULL)) |
|---|
| 81 | 107 | return NULL; |
|---|
| 82 | 108 | |
|---|
| 83 | | if (asprintf (&sdp, "v=0\r\n" |
|---|
| 84 | | "o=- "I64Fu" "I64Fu" %s\r\n" |
|---|
| 85 | | "s=%s\r\n" |
|---|
| 86 | | "i=N/A\r\n" // must be there even if useless |
|---|
| 87 | | // no URL, email and phone here */ |
|---|
| 88 | | "c=%s\r\n" |
|---|
| | 109 | if (asprintf (&sdp, "v=0" |
|---|
| | 110 | "\r\no=- "I64Fu" "I64Fu" %s" |
|---|
| | 111 | "\r\ns=%s" |
|---|
| | 112 | "\r\ni=%s" |
|---|
| | 113 | "%s%s" // optional URL |
|---|
| | 114 | "%s%s" // optional email |
|---|
| | 115 | "%s%s" // optional phone number |
|---|
| | 116 | "\r\nc=%s" |
|---|
| 89 | 117 | // bandwidth not specified |
|---|
| 90 | | "t= 0 0" // one dummy time span |
|---|
| | 118 | "\r\nt= 0 0" // one dummy time span |
|---|
| 91 | 119 | // no repeating |
|---|
| 92 | 120 | // no time zone adjustment (silly idea anyway) |
|---|
| 93 | 121 | // no encryption key (deprecated) |
|---|
| 94 | | "a=tool:"PACKAGE_STRING"\r\n" |
|---|
| 95 | | "a=recvonly\r\n" |
|---|
| 96 | | "a=type:broadcast\r\n" |
|---|
| 97 | | "a=charset:UTF-8\r\n", |
|---|
| | 122 | "\r\na=tool:"PACKAGE_STRING |
|---|
| | 123 | "\r\na=recvonly" |
|---|
| | 124 | "\r\na=type:broadcast" |
|---|
| | 125 | "\r\na=charset:UTF-8" |
|---|
| | 126 | "\r\n", |
|---|
| 98 | 127 | /* o= */ t, t, machine, |
|---|
| 99 | 128 | /* s= */ name, |
|---|
| | 129 | /* i= */ description, |
|---|
| | 130 | /* u= */ preurl, url, |
|---|
| | 131 | /* e= */ premail, email, |
|---|
| | 132 | /* p= */ prephone, phone, |
|---|
| 100 | 133 | /* c= */ conn) == -1) |
|---|
| 101 | 134 | return NULL; |
|---|
| r0336f13 |
r08cb8e6 |
|
| 91 | 91 | void announce_SAPHandlerDestroy( sap_handler_t *p_sap ); |
|---|
| 92 | 92 | |
|---|
| 93 | | char *StartSDP (const char *name, |
|---|
| | 93 | char *StartSDP (const char *name, const char *description, const char *url, |
|---|
| | 94 | const char *email, const char *phone, |
|---|
| 94 | 95 | const struct sockaddr *orig, socklen_t origlen, |
|---|
| 95 | 96 | const struct sockaddr *addr, socklen_t addrlen); |
|---|