FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions | Variables
mmst.c File Reference
#include "avformat.h"
#include "mms.h"
#include "internal.h"
#include "avio_internal.h"
#include "libavutil/intreadwrite.h"
#include "libavcodec/bytestream.h"
#include "network.h"
#include "url.h"

Go to the source code of this file.

Data Structures

struct  MMSTContext
 

Macros

#define LOCAL_ADDRESS   0xc0a80081
 
#define LOCAL_PORT   1037
 

Enumerations

enum  MMSCSPacketType {
  CS_PKT_INITIAL = 0x01, CS_PKT_PROTOCOL_SELECT = 0x02, CS_PKT_MEDIA_FILE_REQUEST = 0x05, CS_PKT_START_FROM_PKT_ID = 0x07,
  CS_PKT_STREAM_PAUSE = 0x09, CS_PKT_STREAM_CLOSE = 0x0d, CS_PKT_MEDIA_HEADER_REQUEST = 0x15, CS_PKT_TIMING_DATA_REQUEST = 0x18,
  CS_PKT_USER_PASSWORD = 0x1a, CS_PKT_KEEPALIVE = 0x1b, CS_PKT_STREAM_ID_REQUEST = 0x33
}
 Client to server packet types. More...
 
enum  MMSSCPacketType {
  SC_PKT_CLIENT_ACCEPTED = 0x01, SC_PKT_PROTOCOL_ACCEPTED = 0x02, SC_PKT_PROTOCOL_FAILED = 0x03, SC_PKT_MEDIA_PKT_FOLLOWS = 0x05,
  SC_PKT_MEDIA_FILE_DETAILS = 0x06, SC_PKT_HEADER_REQUEST_ACCEPTED = 0x11, SC_PKT_TIMING_TEST_REPLY = 0x15, SC_PKT_PASSWORD_REQUIRED = 0x1a,
  SC_PKT_KEEPALIVE = 0x1b, SC_PKT_STREAM_STOPPED = 0x1e, SC_PKT_STREAM_CHANGING = 0x20, SC_PKT_STREAM_ID_ACCEPTED = 0x21,
  SC_PKT_CANCEL = -1, SC_PKT_NO_DATA = -2, SC_PKT_ASF_HEADER = 0x010000, SC_PKT_ASF_MEDIA = 0x010001
}
 Server to client packet types. More...
 

Functions

static void start_command_packet (MMSTContext *mmst, MMSCSPacketType packet_type)
 Create MMST command packet header.
 
static void insert_command_prefixes (MMSContext *mms, uint32_t prefix1, uint32_t prefix2)
 Add prefixes to MMST command packet.
 
static int send_command_packet (MMSTContext *mmst)
 Send a prepared MMST command packet.
 
static void mms_put_utf16 (MMSContext *mms, const uint8_t *src)
 
static int send_time_test_data (MMSTContext *mmst)
 
static int send_protocol_select (MMSTContext *mmst)
 
static int send_media_file_request (MMSTContext *mmst)
 
static void handle_packet_stream_changing_type (MMSTContext *mmst)
 
static int send_keepalive_packet (MMSTContext *mmst)
 
static void pad_media_packet (MMSContext *mms)
 Pad media packets smaller than max_packet_size and/or adjust read position after a seek.
 
static MMSSCPacketType get_tcp_server_response (MMSTContext *mmst)
 Read incoming MMST media, header or command packet.
 
static int mms_safe_send_recv (MMSTContext *mmst, int(*send_fun)(MMSTContext *mmst), const MMSSCPacketType expect_type)
 
static int send_media_header_request (MMSTContext *mmst)
 
static int send_startup_packet (MMSTContext *mmst)
 Send the initial handshake.
 
static int send_stream_selection_request (MMSTContext *mmst)
 Send MMST stream selection command based on the AVStream->discard values.
 
static int send_close_packet (MMSTContext *mmst)
 
static int mms_close (URLContext *h)
 Close the MMSH/MMST connection.
 
static int send_media_packet_request (MMSTContext *mmst)
 
static void clear_stream_buffers (MMSContext *mms)
 
static int mms_open (URLContext *h, const char *uri, int flags)
 
static int mms_read (URLContext *h, uint8_t *buf, int size)
 Read ASF data through the protocol.
 

Variables

URLProtocol ff_mmst_protocol
 

Macro Definition Documentation

#define LOCAL_ADDRESS   0xc0a80081

Definition at line 40 of file mmst.c.

Referenced by send_protocol_select().

#define LOCAL_PORT   1037

Definition at line 41 of file mmst.c.

Referenced by send_protocol_select().

Enumeration Type Documentation

Client to server packet types.

Enumerator:
CS_PKT_INITIAL 
CS_PKT_PROTOCOL_SELECT 
CS_PKT_MEDIA_FILE_REQUEST 
CS_PKT_START_FROM_PKT_ID 
CS_PKT_STREAM_PAUSE 
CS_PKT_STREAM_CLOSE 
CS_PKT_MEDIA_HEADER_REQUEST 
CS_PKT_TIMING_DATA_REQUEST 
CS_PKT_USER_PASSWORD 
CS_PKT_KEEPALIVE 
CS_PKT_STREAM_ID_REQUEST 

Definition at line 43 of file mmst.c.

Server to client packet types.

Enumerator:
SC_PKT_CLIENT_ACCEPTED 

Control packets.

SC_PKT_PROTOCOL_ACCEPTED 
SC_PKT_PROTOCOL_FAILED 
SC_PKT_MEDIA_PKT_FOLLOWS 
SC_PKT_MEDIA_FILE_DETAILS 
SC_PKT_HEADER_REQUEST_ACCEPTED 
SC_PKT_TIMING_TEST_REPLY 
SC_PKT_PASSWORD_REQUIRED 
SC_PKT_KEEPALIVE 
SC_PKT_STREAM_STOPPED 
SC_PKT_STREAM_CHANGING 
SC_PKT_STREAM_ID_ACCEPTED 
SC_PKT_CANCEL 

Pseudo packets.

SC_PKT_NO_DATA 
SC_PKT_ASF_HEADER 

Data packets.

SC_PKT_ASF_MEDIA 

Definition at line 58 of file mmst.c.

Function Documentation

static void start_command_packet ( MMSTContext mmst,
MMSCSPacketType  packet_type 
)
static
static void insert_command_prefixes ( MMSContext mms,
uint32_t  prefix1,
uint32_t  prefix2 
)
static
static int send_command_packet ( MMSTContext mmst)
static
static void mms_put_utf16 ( MMSContext mms,
const uint8_t src 
)
static

Definition at line 155 of file mmst.c.

Referenced by send_media_file_request(), send_protocol_select(), and send_startup_packet().

static int send_time_test_data ( MMSTContext mmst)
static

Definition at line 167 of file mmst.c.

Referenced by mms_open().

static int send_protocol_select ( MMSTContext mmst)
static

Definition at line 174 of file mmst.c.

Referenced by mms_open().

static int send_media_file_request ( MMSTContext mmst)
static

Definition at line 196 of file mmst.c.

Referenced by mms_open().

static void handle_packet_stream_changing_type ( MMSTContext mmst)
static

Definition at line 208 of file mmst.c.

Referenced by get_tcp_server_response().

static int send_keepalive_packet ( MMSTContext mmst)
static

Definition at line 218 of file mmst.c.

Referenced by get_tcp_server_response().

static void pad_media_packet ( MMSContext mms)
static

Pad media packets smaller than max_packet_size and/or adjust read position after a seek.

Definition at line 228 of file mmst.c.

Referenced by get_tcp_server_response().

static MMSSCPacketType get_tcp_server_response ( MMSTContext mmst)
static

Read incoming MMST media, header or command packet.

Definition at line 238 of file mmst.c.

Referenced by mms_safe_send_recv().

static int mms_safe_send_recv ( MMSTContext mmst,
int(*)(MMSTContext *mmst)  send_fun,
const MMSSCPacketType  expect_type 
)
static

Definition at line 372 of file mmst.c.

Referenced by mms_open(), and mms_read().

static int send_media_header_request ( MMSTContext mmst)
static

Definition at line 395 of file mmst.c.

Referenced by mms_open().

static int send_startup_packet ( MMSTContext mmst)
static

Send the initial handshake.

Definition at line 417 of file mmst.c.

Referenced by mms_open().

static int send_stream_selection_request ( MMSTContext mmst)
static

Send MMST stream selection command based on the AVStream->discard values.

Definition at line 437 of file mmst.c.

Referenced by mms_open().

static int send_close_packet ( MMSTContext mmst)
static

Definition at line 452 of file mmst.c.

Referenced by mms_close().

static int mms_close ( URLContext h)
static

Close the MMSH/MMST connection.

Definition at line 461 of file mmst.c.

Referenced by mms_open().

static int send_media_packet_request ( MMSTContext mmst)
static

Definition at line 477 of file mmst.c.

Referenced by mms_open().

static void clear_stream_buffers ( MMSContext mms)
static

Definition at line 496 of file mmst.c.

Referenced by mms_open().

static int mms_open ( URLContext h,
const char *  uri,
int  flags 
)
static

Definition at line 502 of file mmst.c.

static int mms_read ( URLContext h,
uint8_t buf,
int  size 
)
static

Read ASF data through the protocol.

Definition at line 581 of file mmst.c.

Variable Documentation

URLProtocol ff_mmst_protocol
Initial value:
= {
.name = "mmst",
.url_open = mms_open,
.url_read = mms_read,
.url_close = mms_close,
.priv_data_size = sizeof(MMSTContext),
}

Definition at line 622 of file mmst.c.