FFmpeg
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. More...
 
static void insert_command_prefixes (MMSContext *mms, uint32_t prefix1, uint32_t prefix2)
 Add prefixes to MMST command packet. More...
 
static int send_command_packet (MMSTContext *mmst)
 Send a prepared MMST command packet. More...
 
static int 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. More...
 
static MMSSCPacketType get_tcp_server_response (MMSTContext *mmst)
 Read incoming MMST media, header or command packet. More...
 
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. More...
 
static int send_stream_selection_request (MMSTContext *mmst)
 Send MMST stream selection command based on the AVStream->discard values. More...
 
static int send_close_packet (MMSTContext *mmst)
 
static int mms_close (URLContext *h)
 Close the MMSH/MMST connection. More...
 
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. More...
 

Variables

const URLProtocol ff_mmst_protocol
 

Macro Definition Documentation

◆ LOCAL_ADDRESS

#define LOCAL_ADDRESS   0xc0a80081

Definition at line 40 of file mmst.c.

◆ LOCAL_PORT

#define LOCAL_PORT   1037

Definition at line 41 of file mmst.c.

Enumeration Type Documentation

◆ MMSCSPacketType

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.

◆ MMSSCPacketType

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

◆ start_command_packet()

static void start_command_packet ( MMSTContext mmst,
MMSCSPacketType  packet_type 
)
static

◆ insert_command_prefixes()

static void insert_command_prefixes ( MMSContext mms,
uint32_t  prefix1,
uint32_t  prefix2 
)
static

◆ send_command_packet()

static int send_command_packet ( MMSTContext mmst)
static

◆ mms_put_utf16()

static int 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().

◆ send_time_test_data()

static int send_time_test_data ( MMSTContext mmst)
static

Definition at line 170 of file mmst.c.

Referenced by mms_open().

◆ send_protocol_select()

static int send_protocol_select ( MMSTContext mmst)
static

Definition at line 177 of file mmst.c.

Referenced by mms_open().

◆ send_media_file_request()

static int send_media_file_request ( MMSTContext mmst)
static

Definition at line 201 of file mmst.c.

Referenced by mms_open().

◆ handle_packet_stream_changing_type()

static void handle_packet_stream_changing_type ( MMSTContext mmst)
static

Definition at line 215 of file mmst.c.

Referenced by get_tcp_server_response().

◆ send_keepalive_packet()

static int send_keepalive_packet ( MMSTContext mmst)
static

Definition at line 225 of file mmst.c.

Referenced by get_tcp_server_response().

◆ pad_media_packet()

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 235 of file mmst.c.

Referenced by get_tcp_server_response().

◆ get_tcp_server_response()

static MMSSCPacketType get_tcp_server_response ( MMSTContext mmst)
static

Read incoming MMST media, header or command packet.

Definition at line 245 of file mmst.c.

Referenced by mms_safe_send_recv().

◆ 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 379 of file mmst.c.

Referenced by mms_open(), and mms_read().

◆ send_media_header_request()

static int send_media_header_request ( MMSTContext mmst)
static

Definition at line 402 of file mmst.c.

Referenced by mms_open().

◆ send_startup_packet()

static int send_startup_packet ( MMSTContext mmst)
static

Send the initial handshake.

Definition at line 424 of file mmst.c.

Referenced by mms_open().

◆ send_stream_selection_request()

static int send_stream_selection_request ( MMSTContext mmst)
static

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

Definition at line 446 of file mmst.c.

Referenced by mms_open().

◆ send_close_packet()

static int send_close_packet ( MMSTContext mmst)
static

Definition at line 461 of file mmst.c.

Referenced by mms_close().

◆ mms_close()

static int mms_close ( URLContext h)
static

Close the MMSH/MMST connection.

Definition at line 470 of file mmst.c.

Referenced by mms_open().

◆ send_media_packet_request()

static int send_media_packet_request ( MMSTContext mmst)
static

Definition at line 486 of file mmst.c.

Referenced by mms_open().

◆ clear_stream_buffers()

static void clear_stream_buffers ( MMSContext mms)
static

Definition at line 505 of file mmst.c.

Referenced by mms_open().

◆ mms_open()

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

Definition at line 511 of file mmst.c.

◆ mms_read()

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

Read ASF data through the protocol.

Definition at line 591 of file mmst.c.

Variable Documentation

◆ ff_mmst_protocol

const 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 632 of file mmst.c.

URL_PROTOCOL_FLAG_NETWORK
#define URL_PROTOCOL_FLAG_NETWORK
Definition: url.h:33
mms_close
static int mms_close(URLContext *h)
Close the MMSH/MMST connection.
Definition: mmst.c:470
mms_read
static int mms_read(URLContext *h, uint8_t *buf, int size)
Read ASF data through the protocol.
Definition: mmst.c:591
mms_open
static int mms_open(URLContext *h, const char *uri, int flags)
Definition: mmst.c:511
MMSTContext
Definition: mmst.c:88
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561