38 #define CHUNK_HEADER_LENGTH 4
39 #define EXT_HEADER_LENGTH 8
42 #define USERAGENT "User-Agent: NSPlayer/4.1.0.3856\r\n"
45 #define CLIENTGUID "Pragma: xClientGUID={c77e7400-738a-11d2-9add-0020af0a3278}\r\n"
80 int chunk_len, res, ext_header_len;
87 chunk_type =
AV_RL16(chunk_header);
88 chunk_len =
AV_RL16(chunk_header + 2);
105 if (res != ext_header_len) {
109 *
len = chunk_len - ext_header_len;
121 "Data packet length %d exceeds the in_buffer size %"SIZE_SPECIFIER"\n",
173 "Asf header packet len = %d exceed the asf header buf size %d\n",
180 "Recv asf header data len %d != expected len %d\n", res,
len);
196 "Other packet len = %d exceed the in_buffer size %"SIZE_SPECIFIER"\n",
216 char httpname[256], path[256], host[128];
217 char *stream_selection =
NULL;
227 host,
sizeof(host), &port, path,
sizeof(path), mmsh->
location);
230 ff_url_join(httpname,
sizeof(httpname),
"http",
NULL, host, port,
"%s", path);
233 &
h->interrupt_callback) < 0) {
241 "Pragma: no-cache,rate=1.000000,stream-time=0,"
242 "stream-offset=0:0,request-context=%u,max-duration=0\r\n"
244 "Connection: Close\r\n",
268 memset(headers, 0,
sizeof(headers));
270 &
h->interrupt_callback)) < 0) {
274 if (!stream_selection)
284 err =
snprintf(headers,
sizeof(headers),
288 "Pragma: no-cache,rate=1.000000,request-context=%u\r\n"
289 "Pragma: xPlayStrm=1\r\n"
291 "Pragma: stream-switch-count=%d\r\n"
292 "Pragma: stream-switch-entry=%s\r\n"
293 "Pragma: no-cache,rate=1.000000,stream-time=%u"
294 "Connection: Close\r\n",
336 switch (chunk_type) {
388 h->priv_data = mmsh_old;
394 h->priv_data = mmsh_old;
406 if(
pos == 0 && whence == SEEK_CUR)
420 .default_whitelist =
"http,tcp",
int ffurl_alloc(URLContext **puc, const char *filename, int flags, const AVIOInterruptCB *int_cb)
Create a URLContext for accessing to the resource indicated by url, but do not initiate the connectio...
int ffurl_closep(URLContext **hh)
Close the resource accessed by the URLContext h, and free the memory used by it.
int ffurl_connect(URLContext *uc, AVDictionary **options)
Connect an URLContext that has been allocated by ffurl_alloc.
int ffurl_read_complete(URLContext *h, unsigned char *buf, int size)
Read as many bytes as possible (up to size), calling the read function multiple times if necessary.
#define AVIO_FLAG_READ
read-only
#define flags(name, subs,...)
void av_url_split(char *proto, int proto_size, char *authorization, int authorization_size, char *hostname, int hostname_size, int *port_ptr, char *path, int path_size, const char *url)
Split a URL string into components.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
char * av_strdup(const char *s)
Duplicate a string.
size_t av_strlcat(char *dst, const char *src, size_t size)
Append the string src to the string dst, but to a total length of no more than size - 1 bytes,...
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
common internal API header
int ff_mms_asf_header_parser(MMSContext *mms)
int ff_mms_read_header(MMSContext *mms, uint8_t *buf, const int size)
int ff_mms_read_data(MMSContext *mms, uint8_t *buf, const int size)
static ChunkType get_chunk_header(MMSHContext *mmsh, int *len)
static int mmsh_close(URLContext *h)
static int mmsh_read(URLContext *h, uint8_t *buf, int size)
static int get_http_header_data(MMSHContext *mmsh)
static int64_t mmsh_seek(URLContext *h, int64_t pos, int whence)
@ CHUNK_TYPE_STREAM_CHANGE
#define CHUNK_HEADER_LENGTH
static int handle_chunk_type(MMSHContext *mmsh)
static int read_data_packet(MMSHContext *mmsh, const int len)
static int64_t mmsh_read_seek(URLContext *h, int stream_index, int64_t timestamp, int flags)
static int mmsh_open_internal(URLContext *h, const char *uri, int flags, int timestamp, int64_t pos)
const URLProtocol ff_mmsh_protocol
static int mmsh_open(URLContext *h, const char *uri, int flags)
#define EXT_HEADER_LENGTH
int header_parsed
The header has been received and parsed.
int stream_num
stream numbers.
uint8_t * asf_header
Internal handling of the ASF header.
uint8_t in_buffer[65536]
Buffer for incoming packets.
int remaining_in_len
Reading length from incoming buffer.
URLContext * mms_hd
TCP connection handle.
int asf_header_size
Size of stored ASF header.
uint8_t * read_in_ptr
Pointer for reading from incoming buffer.
int request_seq
request packet sequence
int chunk_seq
data packet sequence
const char * protocol_whitelist
int ff_url_join(char *str, int size, const char *proto, const char *authorization, const char *hostname, int port, const char *fmt,...)
unbuffered private I/O API
#define URL_PROTOCOL_FLAG_NETWORK