38 #define CHUNK_HEADER_LENGTH 4   // 2bytes chunk type and 2bytes chunk length. 
   39 #define EXT_HEADER_LENGTH   8   // 4bytes sequence, 2bytes useless and 2bytes chunk length. 
   42 #define USERAGENT  "User-Agent: NSPlayer/4.1.0.3856\r\n" 
   45 #define CLIENTGUID "Pragma: xClientGUID={c77e7400-738a-11d2-9add-0020af0a3278}\r\n" 
   81     int chunk_len, res, ext_header_len;
 
   88     chunk_type = 
AV_RL16(chunk_header);
 
   89     chunk_len  = 
AV_RL16(chunk_header + 2);
 
  106     if (res != ext_header_len) {
 
  110     *len = chunk_len - ext_header_len;
 
  122                "Data packet length %d exceeds the in_buffer size %"SIZE_SPECIFIER"\n",
 
  134                "Chunk length %d exceed packet length %d\n",len, mms->
asf_packet_len);
 
  174                        "Asf header packet len = %d exceed the asf header buf size %d\n",
 
  181                        "Recv asf header data len %d != expected len %d\n", res, len);
 
  197                            "Other packet len = %d exceed the in_buffer size %"SIZE_SPECIFIER"\n",
 
  217     char httpname[256], path[256], host[128];
 
  218     char *stream_selection = 
NULL;
 
  228         host, 
sizeof(host), &port, path, 
sizeof(path), mmsh->
location);
 
  231     ff_url_join(httpname, 
sizeof(httpname), 
"http", 
NULL, host, port, 
"%s", path);
 
  242              "Pragma: no-cache,rate=1.000000,stream-time=0," 
  243              "stream-offset=0:0,request-context=%u,max-duration=0\r\n" 
  245              "Connection: Close\r\n",
 
  269     memset(headers, 0, 
sizeof(headers));
 
  275     if (!stream_selection)
 
  285     err = 
snprintf(headers, 
sizeof(headers),
 
  289                    "Pragma: no-cache,rate=1.000000,request-context=%u\r\n" 
  290                    "Pragma: xPlayStrm=1\r\n" 
  292                    "Pragma: stream-switch-count=%d\r\n" 
  293                    "Pragma: stream-switch-entry=%s\r\n" 
  294                    "Pragma: no-cache,rate=1.000000,stream-time=%u" 
  295                    "Connection: Close\r\n",
 
  337     switch (chunk_type) {
 
  377                         int64_t timestamp, 
int flags)
 
  407     if(pos == 0 && whence == SEEK_CUR)
 
  421     .default_whitelist = 
"http,tcp",
 
static int mmsh_open(URLContext *h, const char *uri, int flags)
 
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. 
 
int request_seq
request packet sequence 
 
#define AVERROR_INVALIDDATA
Invalid data found when processing input. 
 
URLContext * mms_hd
TCP connection handle. 
 
#define URL_PROTOCOL_FLAG_NETWORK
 
uint8_t * read_in_ptr
Pointer for reading from incoming buffer. 
 
static int get_http_header_data(MMSHContext *mmsh)
 
int is_streamed
true if streamed (no seek possible), default = false 
 
int ffurl_connect(URLContext *uc, AVDictionary **options)
Connect an URLContext that has been allocated by ffurl_alloc. 
 
AVIOInterruptCB interrupt_callback
 
static int read_data_packet(MMSHContext *mmsh, const int len)
 
#define EXT_HEADER_LENGTH
 
#define AVIO_FLAG_READ
read-only 
 
int ff_mms_read_header(MMSContext *mms, uint8_t *buf, const int size)
 
int stream_num
stream numbers. 
 
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
 
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
 
int header_parsed
The header has been received and parsed. 
 
static int handle_chunk_type(MMSHContext *mmsh)
 
uint8_t * asf_header
Internal handling of the ASF header. 
 
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development. 
 
static int64_t mmsh_seek(URLContext *h, int64_t pos, int whence)
 
int ff_mms_read_data(MMSContext *mms, uint8_t *buf, const int size)
 
#define CHUNK_HEADER_LENGTH
 
uint8_t in_buffer[65536]
Buffer for incoming packets. 
 
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...
 
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered. 
 
const char * protocol_whitelist
 
static ChunkType get_chunk_header(MMSHContext *mmsh, int *len)
 
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 ffurl_closep(URLContext **hh)
Close the resource accessed by the URLContext h, and free the memory used by it. 
 
int ff_url_join(char *str, int size, const char *proto, const char *authorization, const char *hostname, int port, const char *fmt,...)
 
char * av_strdup(const char *s)
Duplicate a string. 
 
int remaining_in_len
Reading length from incoming buffer. 
 
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)
 
int chunk_seq
data packet sequence 
 
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...
 
int asf_header_size
Size of stored ASF header. 
 
int ffurl_close(URLContext *h)
 
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...
 
const URLProtocol ff_mmsh_protocol
 
static int mmsh_close(URLContext *h)
 
static int mmsh_read(URLContext *h, uint8_t *buf, int size)
 
unbuffered private I/O API 
 
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
 
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
 
int ff_mms_asf_header_parser(MMSContext *mms)