40 #define LOCAL_ADDRESS 0xc0a80081 // FIXME get and use correct local ip address.
41 #define LOCAL_PORT 1037 // as above.
119 uint32_t prefix1, uint32_t prefix2)
130 int exact_length =
FFALIGN(len, 8);
131 int first_length= exact_length - 16;
132 int len8= first_length/8;
143 if(write_result != exact_length) {
145 "Failed to write data of length %d: %d (%s)\n",
146 exact_length, write_result,
147 write_result < 0 ? strerror(
AVUNERROR(write_result)) :
148 "The server closed the connection");
180 char data_string[256];
188 snprintf(data_string,
sizeof(data_string),
"\\\\%d.%d.%d.%d\\%s\\%d",
252 if (read_result != 8) {
253 if(read_result < 0) {
255 "Error reading packet header: %d (%s)\n",
256 read_result, strerror(
AVUNERROR(read_result)));
260 "The server closed the connection\n");
268 int length_remaining, hr;
272 if(read_result != 4) {
274 "Reading command packet length failed: %d (%s)\n",
276 read_result < 0 ? strerror(
AVUNERROR(read_result)) :
277 "The server closed the connection");
278 return read_result < 0 ? read_result :
AVERROR(EIO);
284 if (length_remaining < 0
285 || length_remaining >
sizeof(mms->
in_buffer) - 12) {
288 length_remaining,
sizeof(mms->
in_buffer) - 12);
293 if (read_result != length_remaining) {
295 "Reading pkt data (length=%d) failed: %d (%s)\n",
296 length_remaining, read_result,
297 read_result < 0 ? strerror(
AVUNERROR(read_result)) :
298 "The server closed the connection");
299 return read_result < 0 ? read_result :
AVERROR(EIO);
304 "Server sent a message with packet type 0x%x and error status code 0x%08x\n", packet_type, hr);
308 int length_remaining;
315 length_remaining = (tmp - 8) & 0xffff;
320 if (length_remaining < 0
321 || length_remaining >
sizeof(mms->
in_buffer) - 8) {
323 "Data length %d is invalid or too large (max=%"SIZE_SPECIFIER")\n",
324 length_remaining,
sizeof(mms->
in_buffer));
330 if(read_result != length_remaining) {
332 "Failed to read packet data of size %d: %d (%s)\n",
333 length_remaining, read_result,
334 read_result < 0 ? strerror(
AVUNERROR(read_result)) :
335 "The server closed the connection");
336 return read_result < 0 ? read_result :
AVERROR(EIO);
358 }
else if(packet_id_type == mmst->
packet_id) {
385 int ret = send_fun(mmst);
394 "Corrupt stream (unexpected packet type 0x%x, expected 0x%x)\n",
426 char data_string[256];
433 snprintf(data_string,
sizeof(data_string),
434 "NSPlayer/7.0.0.1956; {%s}; Host: %s",
435 "7E667F5D-A661-495E-A512-F55686DDA178", mmst->
host);
524 sizeof(mmst->
path), uri);
559 "The server does not support MMST (try MMSH or RTSP)\n");
612 "Incoming pktlen %d is larger than ASF pktsize %d\n",
static void pad_media_packet(MMSContext *mms)
Pad media packets smaller than max_packet_size and/or adjust read position after a seek...
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.
static void start_command_packet(MMSTContext *mmst, MMSCSPacketType packet_type)
Create MMST command packet header.
URLContext * mms_hd
TCP connection handle.
int ffurl_open_whitelist(URLContext **puc, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options, const char *whitelist, const char *blacklist, URLContext *parent)
Create an URLContext for accessing to the resource indicated by url, and open it. ...
#define URL_PROTOCOL_FLAG_NETWORK
static int send_media_file_request(MMSTContext *mmst)
char path[256]
Path of the resource being asked for.
uint8_t * read_in_ptr
Pointer for reading from incoming buffer.
int ffurl_write(URLContext *h, const unsigned char *buf, int size)
Write size bytes from buf to the resource accessed by h.
int is_streamed
true if streamed (no seek possible), default = false
AVIOInterruptCB interrupt_callback
unsigned int header_packet_id
default is 2.
int ff_mms_read_header(MMSContext *mms, uint8_t *buf, const int size)
int stream_num
stream numbers.
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.
uint8_t * asf_header
Internal handling of the ASF header.
static int send_media_header_request(MMSTContext *mmst)
MMSCSPacketType
Client to server packet types.
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
int ff_mms_read_data(MMSContext *mms, uint8_t *buf, const int size)
MMSSCPacketType
Server to client packet types.
uint8_t in_buffer[65536]
Buffer for incoming packets.
static int mms_open(URLContext *h, const char *uri, int flags)
int packet_id
Identifier for packets in the current stream.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * protocol_whitelist
static void handle_packet_stream_changing_type(MMSTContext *mmst)
static int send_stream_selection_request(MMSTContext *mmst)
Send MMST stream selection command based on the AVStream->discard values.
static void clear_stream_buffers(MMSContext *mms)
uint8_t * write_out_ptr
Buffer for outgoing packets.
static int send_close_packet(MMSTContext *mmst)
static int send_keepalive_packet(MMSTContext *mmst)
static int mms_read(URLContext *h, uint8_t *buf, int size)
Read ASF data through the protocol.
static int send_command_packet(MMSTContext *mmst)
Send a prepared MMST command packet.
int incoming_packet_seq
Incoming packet sequence number.
int ff_url_join(char *str, int size, const char *proto, const char *authorization, const char *hostname, int port, const char *fmt,...)
uint8_t out_buffer[512]
Buffer for outgoing packet.
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
const char * protocol_blacklist
int remaining_in_len
Reading length from incoming buffer.
static int mms_put_utf16(MMSContext *mms, const uint8_t *src)
const URLProtocol ff_mmst_protocol
#define AVIO_FLAG_READ_WRITE
read-write pseudo flag
static int send_startup_packet(MMSTContext *mmst)
Send the initial handshake.
int avio_put_str16le(AVIOContext *s, const char *str)
Convert an UTF-8 string to UTF-16LE and write it.
int incoming_flags
Incoming packet flags.
static int send_time_test_data(MMSTContext *mmst)
int asf_header_size
Size of stored ASF header.
int ffurl_close(URLContext *h)
static void insert_command_prefixes(MMSContext *mms, uint32_t prefix1, uint32_t prefix2)
Add prefixes to MMST command packet.
int outgoing_packet_seq
Outgoing packet sequence number.
int ffio_init_context(AVIOContext *s, unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int(*read_packet)(void *opaque, uint8_t *buf, int buf_size), int(*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence))
static int send_media_packet_request(MMSTContext *mmst)
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...
static int send_protocol_select(MMSTContext *mmst)
static int mms_safe_send_recv(MMSTContext *mmst, int(*send_fun)(MMSTContext *mmst), const MMSSCPacketType expect_type)
unbuffered private I/O API
static MMSSCPacketType get_tcp_server_response(MMSTContext *mmst)
Read incoming MMST media, header or command packet.
char host[128]
Host of the resources.
static int mms_close(URLContext *h)
Close the MMSH/MMST connection.
#define MKTAG(a, b, c, d)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
int ff_mms_asf_header_parser(MMSContext *mms)