FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
rtmpproto.c File Reference
#include "libavcodec/bytestream.h"
#include "libavutil/avstring.h"
#include "libavutil/base64.h"
#include "libavutil/intfloat.h"
#include "libavutil/lfg.h"
#include "libavutil/md5.h"
#include "libavutil/opt.h"
#include "libavutil/random_seed.h"
#include "avformat.h"
#include "internal.h"
#include "network.h"
#include "flv.h"
#include "rtmp.h"
#include "rtmpcrypt.h"
#include "rtmppkt.h"
#include "url.h"

Go to the source code of this file.

Data Structures

struct  TrackedMethod
 
struct  RTMPContext
 protocol handler context More...
 

Macros

#define APP_MAX_LENGTH   1024
 
#define TCURL_MAX_LENGTH   1024
 
#define FLASHVER_MAX_LENGTH   64
 
#define RTMP_PKTDATA_DEFAULT_SIZE   4096
 
#define RTMP_HEADER   11
 
#define PLAYER_KEY_OPEN_PART_LEN   30
 length of partial key used for first client digest signing More...
 
#define SERVER_KEY_OPEN_PART_LEN   36
 length of partial key used for first server digest signing More...
 
#define RTMP_CTRL_ABORT_MESSAGE   (2)
 
#define OFFSET(x)   offsetof(RTMPContext, x)
 
#define DEC   AV_OPT_FLAG_DECODING_PARAM
 
#define ENC   AV_OPT_FLAG_ENCODING_PARAM
 
#define RTMP_PROTOCOL_0(flavor)
 
#define RTMP_PROTOCOL_1(flavor)
 
#define RTMP_PROTOCOL_2(flavor, enabled)   RTMP_PROTOCOL_ ## enabled(flavor)
 
#define RTMP_PROTOCOL_3(flavor, config)   RTMP_PROTOCOL_2(flavor, config)
 
#define RTMP_PROTOCOL(flavor, uppercase)   RTMP_PROTOCOL_3(flavor, CONFIG_ ## uppercase ## _PROTOCOL)
 

Enumerations

enum  ClientState {
  STATE_START, STATE_HANDSHAKED, STATE_FCPUBLISH, STATE_PLAYING,
  STATE_SEEKING, STATE_PUBLISHING, STATE_RECEIVING, STATE_SENDING,
  STATE_STOPPED
}
 RTMP protocol handler state. More...
 

Functions

static int handle_chunk_size (URLContext *s, RTMPPacket *pkt)
 
static int handle_window_ack_size (URLContext *s, RTMPPacket *pkt)
 
static int handle_set_peer_bw (URLContext *s, RTMPPacket *pkt)
 
static int add_tracked_method (RTMPContext *rt, const char *name, int id)
 
static void del_tracked_method (RTMPContext *rt, int index)
 
static int find_tracked_method (URLContext *s, RTMPPacket *pkt, int offset, char **tracked_method)
 
static void free_tracked_methods (RTMPContext *rt)
 
static int rtmp_send_packet (RTMPContext *rt, RTMPPacket *pkt, int track)
 
static int rtmp_write_amf_data (URLContext *s, char *param, uint8_t **p)
 
static int gen_connect (URLContext *s, RTMPContext *rt)
 Generate 'connect' call and send it to the server. More...
 
static int read_connect (URLContext *s, RTMPContext *rt)
 
static int gen_release_stream (URLContext *s, RTMPContext *rt)
 Generate 'releaseStream' call and send it to the server. More...
 
static int gen_fcpublish_stream (URLContext *s, RTMPContext *rt)
 Generate 'FCPublish' call and send it to the server. More...
 
static int gen_fcunpublish_stream (URLContext *s, RTMPContext *rt)
 Generate 'FCUnpublish' call and send it to the server. More...
 
static int gen_create_stream (URLContext *s, RTMPContext *rt)
 Generate 'createStream' call and send it to the server. More...
 
static int gen_delete_stream (URLContext *s, RTMPContext *rt)
 Generate 'deleteStream' call and send it to the server. More...
 
static int gen_get_stream_length (URLContext *s, RTMPContext *rt)
 Generate 'getStreamLength' call and send it to the server. More...
 
static int gen_buffer_time (URLContext *s, RTMPContext *rt)
 Generate client buffer time and send it to the server. More...
 
static int gen_play (URLContext *s, RTMPContext *rt)
 Generate 'play' call and send it to the server, then ping the server to start actual playing. More...
 
static int gen_seek (URLContext *s, RTMPContext *rt, int64_t timestamp)
 
static int gen_pause (URLContext *s, RTMPContext *rt, int pause, uint32_t timestamp)
 Generate a pause packet that either pauses or unpauses the current stream. More...
 
static int gen_publish (URLContext *s, RTMPContext *rt)
 Generate 'publish' call and send it to the server. More...
 
static int gen_pong (URLContext *s, RTMPContext *rt, RTMPPacket *ppkt)
 Generate ping reply and send it to the server. More...
 
static int gen_swf_verification (URLContext *s, RTMPContext *rt)
 Generate SWF verification message and send it to the server. More...
 
static int gen_window_ack_size (URLContext *s, RTMPContext *rt)
 Generate window acknowledgement size message and send it to the server. More...
 
static int gen_check_bw (URLContext *s, RTMPContext *rt)
 Generate check bandwidth message and send it to the server. More...
 
static int gen_bytes_read (URLContext *s, RTMPContext *rt, uint32_t ts)
 Generate report on bytes read so far and send it to the server. More...
 
static int gen_fcsubscribe_stream (URLContext *s, RTMPContext *rt, const char *subscribe)
 
static int rtmp_handshake_imprint_with_digest (uint8_t *buf, int encrypted)
 Put HMAC-SHA2 digest of packet data (except for the bytes where this digest will be stored) into that packet. More...
 
static int rtmp_validate_digest (uint8_t *buf, int off)
 Verify that the received server response has the expected digest value. More...
 
static int rtmp_calc_swf_verification (URLContext *s, RTMPContext *rt, uint8_t *buf)
 
static int rtmp_calc_swfhash (URLContext *s)
 
static int rtmp_handshake (URLContext *s, RTMPContext *rt)
 Perform handshake with the server by means of exchanging pseudorandom data signed with HMAC-SHA2 digest. More...
 
static int rtmp_receive_hs_packet (RTMPContext *rt, uint32_t *first_int, uint32_t *second_int, char *arraydata, int size)
 
static int rtmp_send_hs_packet (RTMPContext *rt, uint32_t first_int, uint32_t second_int, char *arraydata, int size)
 
static int rtmp_server_handshake (URLContext *s, RTMPContext *rt)
 rtmp handshake server side More...
 
static int handle_user_control (URLContext *s, RTMPPacket *pkt)
 
static int do_adobe_auth (RTMPContext *rt, const char *user, const char *salt, const char *opaque, const char *challenge)
 
static int do_llnw_auth (RTMPContext *rt, const char *user, const char *nonce)
 
static int handle_connect_error (URLContext *s, const char *desc)
 
static int handle_invoke_error (URLContext *s, RTMPPacket *pkt)
 
static int write_begin (URLContext *s)
 
static int write_status (URLContext *s, RTMPPacket *pkt, const char *status, const char *filename)
 
static int send_invoke_response (URLContext *s, RTMPPacket *pkt)
 
static int read_number_result (RTMPPacket *pkt, double *number)
 Read the AMF_NUMBER response ("_result") to a function call (e.g. More...
 
static int handle_invoke_result (URLContext *s, RTMPPacket *pkt)
 
static int handle_invoke_status (URLContext *s, RTMPPacket *pkt)
 
static int handle_invoke (URLContext *s, RTMPPacket *pkt)
 
static int update_offset (RTMPContext *rt, int size)
 
static int append_flv_data (RTMPContext *rt, RTMPPacket *pkt, int skip)
 
static int handle_notify (URLContext *s, RTMPPacket *pkt)
 
static int rtmp_parse_result (URLContext *s, RTMPContext *rt, RTMPPacket *pkt)
 Parse received packet and possibly perform some action depending on the packet contents. More...
 
static int handle_metadata (RTMPContext *rt, RTMPPacket *pkt)
 
static int get_packet (URLContext *s, int for_header)
 Interact with the server by receiving and sending RTMP packets until there is some significant data (media data or expected status notification). More...
 
static int rtmp_close (URLContext *h)
 
static int inject_fake_duration_metadata (RTMPContext *rt)
 Insert a fake onMetadata packet into the FLV stream to notify the FLV demuxer about the duration of the stream. More...
 
static int rtmp_open (URLContext *s, const char *uri, int flags, AVDictionary **opts)
 Open RTMP connection and verify that the stream can be played. More...
 
static int rtmp_read (URLContext *s, uint8_t *buf, int size)
 
static int64_t rtmp_seek (URLContext *s, int stream_index, int64_t timestamp, int flags)
 
static int rtmp_pause (URLContext *s, int pause)
 
static int rtmp_write (URLContext *s, const uint8_t *buf, int size)
 

Variables

static const uint8_t rtmp_player_key []
 Client key used for digest signing. More...
 
static const uint8_t rtmp_server_key []
 Key used for RTMP server digest signing. More...
 
static const AVOption rtmp_options []
 

Detailed Description

RTMP protocol

Definition in file rtmpproto.c.

Macro Definition Documentation

◆ APP_MAX_LENGTH

#define APP_MAX_LENGTH   1024

Definition at line 50 of file rtmpproto.c.

◆ TCURL_MAX_LENGTH

#define TCURL_MAX_LENGTH   1024

Definition at line 51 of file rtmpproto.c.

◆ FLASHVER_MAX_LENGTH

#define FLASHVER_MAX_LENGTH   64

Definition at line 52 of file rtmpproto.c.

◆ RTMP_PKTDATA_DEFAULT_SIZE

#define RTMP_PKTDATA_DEFAULT_SIZE   4096

Definition at line 53 of file rtmpproto.c.

◆ RTMP_HEADER

#define RTMP_HEADER   11

Definition at line 54 of file rtmpproto.c.

◆ PLAYER_KEY_OPEN_PART_LEN

#define PLAYER_KEY_OPEN_PART_LEN   30

length of partial key used for first client digest signing

Definition at line 134 of file rtmpproto.c.

◆ SERVER_KEY_OPEN_PART_LEN

#define SERVER_KEY_OPEN_PART_LEN   36

length of partial key used for first server digest signing

Definition at line 145 of file rtmpproto.c.

◆ RTMP_CTRL_ABORT_MESSAGE

#define RTMP_CTRL_ABORT_MESSAGE   (2)

Definition at line 407 of file rtmpproto.c.

◆ OFFSET

#define OFFSET (   x)    offsetof(RTMPContext, x)

Definition at line 3093 of file rtmpproto.c.

◆ DEC

#define DEC   AV_OPT_FLAG_DECODING_PARAM

Definition at line 3094 of file rtmpproto.c.

◆ ENC

#define ENC   AV_OPT_FLAG_ENCODING_PARAM

Definition at line 3095 of file rtmpproto.c.

◆ RTMP_PROTOCOL_0

#define RTMP_PROTOCOL_0 (   flavor)

Definition at line 3122 of file rtmpproto.c.

◆ RTMP_PROTOCOL_1

#define RTMP_PROTOCOL_1 (   flavor)
Value:
static const AVClass flavor##_class = { \
.class_name = #flavor, \
.item_name = av_default_item_name, \
.option = rtmp_options, \
.version = LIBAVUTIL_VERSION_INT, \
}; \
\
const URLProtocol ff_##flavor##_protocol = { \
.name = #flavor, \
.url_open2 = rtmp_open, \
.url_read = rtmp_read, \
.url_read_seek = rtmp_seek, \
.url_read_pause = rtmp_pause, \
.url_write = rtmp_write, \
.url_close = rtmp_close, \
.priv_data_size = sizeof(RTMPContext), \
.priv_data_class= &flavor##_class, \
};

Definition at line 3123 of file rtmpproto.c.

◆ RTMP_PROTOCOL_2

#define RTMP_PROTOCOL_2 (   flavor,
  enabled 
)    RTMP_PROTOCOL_ ## enabled(flavor)

Definition at line 3143 of file rtmpproto.c.

◆ RTMP_PROTOCOL_3

#define RTMP_PROTOCOL_3 (   flavor,
  config 
)    RTMP_PROTOCOL_2(flavor, config)

Definition at line 3145 of file rtmpproto.c.

◆ RTMP_PROTOCOL

#define RTMP_PROTOCOL (   flavor,
  uppercase 
)    RTMP_PROTOCOL_3(flavor, CONFIG_ ## uppercase ## _PROTOCOL)

Definition at line 3147 of file rtmpproto.c.

Enumeration Type Documentation

◆ ClientState

RTMP protocol handler state.

Enumerator
STATE_START 

client has not done anything yet

STATE_HANDSHAKED 

client has performed handshake

STATE_FCPUBLISH 

client FCPublishing stream (for output)

STATE_PLAYING 

client has started receiving multimedia data from server

STATE_SEEKING 

client has started the seek operation. Back on STATE_PLAYING when the time comes

STATE_PUBLISHING 

client has started sending multimedia data to server (for output)

STATE_RECEIVING 

received a publish command (for input)

STATE_SENDING 

received a play command (for output)

STATE_STOPPED 

the broadcast has been stopped

Definition at line 57 of file rtmpproto.c.

Function Documentation

◆ handle_chunk_size()

static int handle_chunk_size ( URLContext s,
RTMPPacket pkt 
)
static

Definition at line 1491 of file rtmpproto.c.

Referenced by read_connect(), and rtmp_parse_result().

◆ handle_window_ack_size()

static int handle_window_ack_size ( URLContext s,
RTMPPacket pkt 
)
static

Definition at line 1578 of file rtmpproto.c.

Referenced by read_connect(), and rtmp_parse_result().

◆ handle_set_peer_bw()

static int handle_set_peer_bw ( URLContext s,
RTMPPacket pkt 
)
static

Definition at line 1551 of file rtmpproto.c.

Referenced by read_connect(), and rtmp_parse_result().

◆ add_tracked_method()

static int add_tracked_method ( RTMPContext rt,
const char *  name,
int  id 
)
static

Definition at line 161 of file rtmpproto.c.

Referenced by rtmp_send_packet().

◆ del_tracked_method()

static void del_tracked_method ( RTMPContext rt,
int  index 
)
static

Definition at line 184 of file rtmpproto.c.

Referenced by find_tracked_method().

◆ find_tracked_method()

static int find_tracked_method ( URLContext s,
RTMPPacket pkt,
int  offset,
char **  tracked_method 
)
static

Definition at line 191 of file rtmpproto.c.

Referenced by handle_invoke_error(), and handle_invoke_result().

◆ free_tracked_methods()

static void free_tracked_methods ( RTMPContext rt)
static

Definition at line 216 of file rtmpproto.c.

Referenced by rtmp_close(), and rtmp_open().

◆ rtmp_send_packet()

static int rtmp_send_packet ( RTMPContext rt,
RTMPPacket pkt,
int  track 
)
static

◆ rtmp_write_amf_data()

static int rtmp_write_amf_data ( URLContext s,
char *  param,
uint8_t **  p 
)
static

Definition at line 255 of file rtmpproto.c.

Referenced by gen_connect().

◆ gen_connect()

static int gen_connect ( URLContext s,
RTMPContext rt 
)
static

Generate 'connect' call and send it to the server.

Definition at line 318 of file rtmpproto.c.

Referenced by rtmp_open().

◆ read_connect()

static int read_connect ( URLContext s,
RTMPContext rt 
)
static

Definition at line 409 of file rtmpproto.c.

Referenced by rtmp_open().

◆ gen_release_stream()

static int gen_release_stream ( URLContext s,
RTMPContext rt 
)
static

Generate 'releaseStream' call and send it to the server.

It should make the server release some channel for media streams.

Definition at line 597 of file rtmpproto.c.

Referenced by handle_invoke_result().

◆ gen_fcpublish_stream()

static int gen_fcpublish_stream ( URLContext s,
RTMPContext rt 
)
static

Generate 'FCPublish' call and send it to the server.

It should make the server prepare for receiving media streams.

Definition at line 621 of file rtmpproto.c.

Referenced by handle_invoke_result().

◆ gen_fcunpublish_stream()

static int gen_fcunpublish_stream ( URLContext s,
RTMPContext rt 
)
static

Generate 'FCUnpublish' call and send it to the server.

It should make the server destroy stream.

Definition at line 645 of file rtmpproto.c.

Referenced by rtmp_close().

◆ gen_create_stream()

static int gen_create_stream ( URLContext s,
RTMPContext rt 
)
static

Generate 'createStream' call and send it to the server.

It should make the server allocate some channel for media streams.

Definition at line 669 of file rtmpproto.c.

Referenced by handle_invoke_result().

◆ gen_delete_stream()

static int gen_delete_stream ( URLContext s,
RTMPContext rt 
)
static

Generate 'deleteStream' call and send it to the server.

It should make the server remove some channel for media streams.

Definition at line 694 of file rtmpproto.c.

Referenced by rtmp_close().

◆ gen_get_stream_length()

static int gen_get_stream_length ( URLContext s,
RTMPContext rt 
)
static

Generate 'getStreamLength' call and send it to the server.

If the server knows the duration of the selected stream, it will reply with the duration in seconds.

Definition at line 720 of file rtmpproto.c.

Referenced by handle_invoke_result().

◆ gen_buffer_time()

static int gen_buffer_time ( URLContext s,
RTMPContext rt 
)
static

Generate client buffer time and send it to the server.

Definition at line 742 of file rtmpproto.c.

Referenced by handle_invoke_result().

◆ gen_play()

static int gen_play ( URLContext s,
RTMPContext rt 
)
static

Generate 'play' call and send it to the server, then ping the server to start actual playing.

Definition at line 764 of file rtmpproto.c.

Referenced by handle_invoke_result().

◆ gen_seek()

static int gen_seek ( URLContext s,
RTMPContext rt,
int64_t  timestamp 
)
static

Definition at line 788 of file rtmpproto.c.

Referenced by rtmp_seek().

◆ gen_pause()

static int gen_pause ( URLContext s,
RTMPContext rt,
int  pause,
uint32_t  timestamp 
)
static

Generate a pause packet that either pauses or unpauses the current stream.

Definition at line 814 of file rtmpproto.c.

Referenced by rtmp_pause().

◆ gen_publish()

static int gen_publish ( URLContext s,
RTMPContext rt 
)
static

Generate 'publish' call and send it to the server.

Definition at line 841 of file rtmpproto.c.

Referenced by handle_invoke_result().

◆ gen_pong()

static int gen_pong ( URLContext s,
RTMPContext rt,
RTMPPacket ppkt 
)
static

Generate ping reply and send it to the server.

Definition at line 868 of file rtmpproto.c.

Referenced by handle_user_control().

◆ gen_swf_verification()

static int gen_swf_verification ( URLContext s,
RTMPContext rt 
)
static

Generate SWF verification message and send it to the server.

Definition at line 894 of file rtmpproto.c.

Referenced by handle_user_control().

◆ gen_window_ack_size()

static int gen_window_ack_size ( URLContext s,
RTMPContext rt 
)
static

Generate window acknowledgement size message and send it to the server.

Definition at line 915 of file rtmpproto.c.

Referenced by handle_invoke_result().

◆ gen_check_bw()

static int gen_check_bw ( URLContext s,
RTMPContext rt 
)
static

Generate check bandwidth message and send it to the server.

Definition at line 934 of file rtmpproto.c.

Referenced by handle_invoke().

◆ gen_bytes_read()

static int gen_bytes_read ( URLContext s,
RTMPContext rt,
uint32_t  ts 
)
static

Generate report on bytes read so far and send it to the server.

Definition at line 955 of file rtmpproto.c.

Referenced by get_packet().

◆ gen_fcsubscribe_stream()

static int gen_fcsubscribe_stream ( URLContext s,
RTMPContext rt,
const char *  subscribe 
)
static

Definition at line 971 of file rtmpproto.c.

Referenced by handle_invoke_result().

◆ rtmp_handshake_imprint_with_digest()

static int rtmp_handshake_imprint_with_digest ( uint8_t *  buf,
int  encrypted 
)
static

Put HMAC-SHA2 digest of packet data (except for the bytes where this digest will be stored) into that packet.

Parameters
bufhandshake data (1536 bytes)
encrypteduse an encrypted connection (RTMPE)
Returns
offset to the digest inside input data

Definition at line 999 of file rtmpproto.c.

Referenced by rtmp_handshake().

◆ rtmp_validate_digest()

static int rtmp_validate_digest ( uint8_t *  buf,
int  off 
)
static

Verify that the received server response has the expected digest value.

Parameters
bufhandshake data received from the server (1536 bytes)
offposition to search digest offset from
Returns
0 if digest is valid, digest position otherwise

Definition at line 1024 of file rtmpproto.c.

Referenced by rtmp_handshake().

◆ rtmp_calc_swf_verification()

static int rtmp_calc_swf_verification ( URLContext s,
RTMPContext rt,
uint8_t *  buf 
)
static

Definition at line 1042 of file rtmpproto.c.

Referenced by rtmp_handshake().

◆ rtmp_calc_swfhash()

static int rtmp_calc_swfhash ( URLContext s)
static

Definition at line 1110 of file rtmpproto.c.

Referenced by rtmp_open().

◆ rtmp_handshake()

static int rtmp_handshake ( URLContext s,
RTMPContext rt 
)
static

Perform handshake with the server by means of exchanging pseudorandom data signed with HMAC-SHA2 digest.

Returns
0 if handshake succeeds, negative value otherwise

Definition at line 1197 of file rtmpproto.c.

Referenced by rtmp_open().

◆ rtmp_receive_hs_packet()

static int rtmp_receive_hs_packet ( RTMPContext rt,
uint32_t *  first_int,
uint32_t *  second_int,
char *  arraydata,
int  size 
)
static

Definition at line 1376 of file rtmpproto.c.

Referenced by rtmp_server_handshake().

◆ rtmp_send_hs_packet()

static int rtmp_send_hs_packet ( RTMPContext rt,
uint32_t  first_int,
uint32_t  second_int,
char *  arraydata,
int  size 
)
static

Definition at line 1397 of file rtmpproto.c.

Referenced by rtmp_server_handshake().

◆ rtmp_server_handshake()

static int rtmp_server_handshake ( URLContext s,
RTMPContext rt 
)
static

rtmp handshake server side

Definition at line 1417 of file rtmpproto.c.

Referenced by rtmp_open().

◆ handle_user_control()

static int handle_user_control ( URLContext s,
RTMPPacket pkt 
)
static

Definition at line 1524 of file rtmpproto.c.

Referenced by rtmp_parse_result().

◆ do_adobe_auth()

static int do_adobe_auth ( RTMPContext rt,
const char *  user,
const char *  salt,
const char *  opaque,
const char *  challenge 
)
static

Definition at line 1604 of file rtmpproto.c.

Referenced by handle_connect_error().

◆ do_llnw_auth()

static int do_llnw_auth ( RTMPContext rt,
const char *  user,
const char *  nonce 
)
static

Definition at line 1643 of file rtmpproto.c.

Referenced by handle_connect_error().

◆ handle_connect_error()

static int handle_connect_error ( URLContext s,
const char *  desc 
)
static

Definition at line 1700 of file rtmpproto.c.

Referenced by handle_invoke_error().

◆ handle_invoke_error()

static int handle_invoke_error ( URLContext s,
RTMPPacket pkt 
)
static

Definition at line 1791 of file rtmpproto.c.

Referenced by handle_invoke().

◆ write_begin()

static int write_begin ( URLContext s)
static

Definition at line 1830 of file rtmpproto.c.

Referenced by send_invoke_response().

◆ write_status()

static int write_status ( URLContext s,
RTMPPacket pkt,
const char *  status,
const char *  filename 
)
static

Definition at line 1856 of file rtmpproto.c.

Referenced by send_invoke_response().

◆ send_invoke_response()

static int send_invoke_response ( URLContext s,
RTMPPacket pkt 
)
static

Definition at line 1899 of file rtmpproto.c.

Referenced by handle_invoke().

◆ read_number_result()

static int read_number_result ( RTMPPacket pkt,
double *  number 
)
static

Read the AMF_NUMBER response ("_result") to a function call (e.g.

createStream()). This response should be made up of the AMF_STRING "result", a NULL object and then the response encoded as AMF_NUMBER. On a successful response, we will return set the value to number (otherwise number will not be changed).

Returns
0 if reading the value succeeds, negative value otherwise

Definition at line 2015 of file rtmpproto.c.

Referenced by handle_invoke_result().

◆ handle_invoke_result()

static int handle_invoke_result ( URLContext s,
RTMPPacket pkt 
)
static

Definition at line 2045 of file rtmpproto.c.

Referenced by handle_invoke().

◆ handle_invoke_status()

static int handle_invoke_status ( URLContext s,
RTMPPacket pkt 
)
static

Definition at line 2117 of file rtmpproto.c.

Referenced by handle_invoke().

◆ handle_invoke()

static int handle_invoke ( URLContext s,
RTMPPacket pkt 
)
static

Definition at line 2154 of file rtmpproto.c.

Referenced by rtmp_parse_result().

◆ update_offset()

static int update_offset ( RTMPContext rt,
int  size 
)
static

Definition at line 2185 of file rtmpproto.c.

Referenced by append_flv_data(), and handle_metadata().

◆ append_flv_data()

static int append_flv_data ( RTMPContext rt,
RTMPPacket pkt,
int  skip 
)
static

Definition at line 2204 of file rtmpproto.c.

Referenced by get_packet(), and handle_notify().

◆ handle_notify()

static int handle_notify ( URLContext s,
RTMPPacket pkt 
)
static

Definition at line 2237 of file rtmpproto.c.

Referenced by get_packet().

◆ rtmp_parse_result()

static int rtmp_parse_result ( URLContext s,
RTMPContext rt,
RTMPPacket pkt 
)
static

Parse received packet and possibly perform some action depending on the packet contents.

Returns
0 for no errors, negative values for serious errors which prevent further communications, positive values for uncritical errors

Definition at line 2300 of file rtmpproto.c.

Referenced by get_packet(), and rtmp_write().

◆ handle_metadata()

static int handle_metadata ( RTMPContext rt,
RTMPPacket pkt 
)
static

Definition at line 2345 of file rtmpproto.c.

Referenced by get_packet().

◆ get_packet()

static int get_packet ( URLContext s,
int  for_header 
)
static

Interact with the server by receiving and sending RTMP packets until there is some significant data (media data or expected status notification).

Parameters
sreading context
for_headernon-zero value tells function to work until it gets notification from the server that playing has been started, otherwise function will work until some media data is received (or an error happens)
Returns
0 for successful operation, negative value in case of error

Definition at line 2406 of file rtmpproto.c.

Referenced by rtmp_open(), and rtmp_read().

◆ rtmp_close()

static int rtmp_close ( URLContext h)
static

Definition at line 2491 of file rtmpproto.c.

Referenced by rtmp_open().

◆ inject_fake_duration_metadata()

static int inject_fake_duration_metadata ( RTMPContext rt)
static

Insert a fake onMetadata packet into the FLV stream to notify the FLV demuxer about the duration of the stream.

This should only be done if there was no real onMetadata packet sent by the server at the start of the stream and if we were able to retrieve a valid duration via a getStreamLength call.

Returns
0 for successful operation, negative value in case of error

Definition at line 2527 of file rtmpproto.c.

Referenced by rtmp_open().

◆ rtmp_open()

static int rtmp_open ( URLContext s,
const char *  uri,
int  flags,
AVDictionary **  opts 
)
static

Open RTMP connection and verify that the stream can be played.

URL syntax: rtmp://server[:port][/app][/playpath] where 'app' is first one or two directories in the path (e.g. /ondemand/, /flash/live/, etc.) and 'playpath' is a file name (the rest of the path, may be prefixed with "mp4:")

Definition at line 2590 of file rtmpproto.c.

◆ rtmp_read()

static int rtmp_read ( URLContext s,
uint8_t *  buf,
int  size 
)
static

Definition at line 2891 of file rtmpproto.c.

◆ rtmp_seek()

static int64_t rtmp_seek ( URLContext s,
int  stream_index,
int64_t  timestamp,
int  flags 
)
static

Definition at line 2918 of file rtmpproto.c.

◆ rtmp_pause()

static int rtmp_pause ( URLContext s,
int  pause 
)
static

Definition at line 2938 of file rtmpproto.c.

◆ rtmp_write()

static int rtmp_write ( URLContext s,
const uint8_t *  buf,
int  size 
)
static

Definition at line 2952 of file rtmpproto.c.

Variable Documentation

◆ rtmp_player_key

const uint8_t rtmp_player_key[]
static
Initial value:
= {
'G', 'e', 'n', 'u', 'i', 'n', 'e', ' ', 'A', 'd', 'o', 'b', 'e', ' ',
'F', 'l', 'a', 's', 'h', ' ', 'P', 'l', 'a', 'y', 'e', 'r', ' ', '0', '0', '1',
0xF0, 0xEE, 0xC2, 0x4A, 0x80, 0x68, 0xBE, 0xE8, 0x2E, 0x00, 0xD0, 0xD1, 0x02,
0x9E, 0x7E, 0x57, 0x6E, 0xEC, 0x5D, 0x2D, 0x29, 0x80, 0x6F, 0xAB, 0x93, 0xB8,
0xE6, 0x36, 0xCF, 0xEB, 0x31, 0xAE
}

Client key used for digest signing.

Definition at line 136 of file rtmpproto.c.

Referenced by rtmp_handshake(), and rtmp_handshake_imprint_with_digest().

◆ rtmp_server_key

const uint8_t rtmp_server_key[]
static
Initial value:
= {
'G', 'e', 'n', 'u', 'i', 'n', 'e', ' ', 'A', 'd', 'o', 'b', 'e', ' ',
'F', 'l', 'a', 's', 'h', ' ', 'M', 'e', 'd', 'i', 'a', ' ',
'S', 'e', 'r', 'v', 'e', 'r', ' ', '0', '0', '1',
0xF0, 0xEE, 0xC2, 0x4A, 0x80, 0x68, 0xBE, 0xE8, 0x2E, 0x00, 0xD0, 0xD1, 0x02,
0x9E, 0x7E, 0x57, 0x6E, 0xEC, 0x5D, 0x2D, 0x29, 0x80, 0x6F, 0xAB, 0x93, 0xB8,
0xE6, 0x36, 0xCF, 0xEB, 0x31, 0xAE
}

Key used for RTMP server digest signing.

Definition at line 147 of file rtmpproto.c.

Referenced by rtmp_handshake(), and rtmp_validate_digest().

◆ rtmp_options

const AVOption rtmp_options[]
static
Initial value:
= {
{"rtmp_app", "Name of application to connect to on the RTMP server", OFFSET(app), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
{"rtmp_buffer", "Set buffer time in milliseconds. The default is 3000.", OFFSET(client_buffer_time), AV_OPT_TYPE_INT, {.i64 = 3000}, 0, INT_MAX, DEC|ENC},
{"rtmp_conn", "Append arbitrary AMF data to the Connect message", OFFSET(conn), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
{"rtmp_flashver", "Version of the Flash plugin used to run the SWF player.", OFFSET(flashver), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
{"rtmp_flush_interval", "Number of packets flushed in the same request (RTMPT only).", OFFSET(flush_interval), AV_OPT_TYPE_INT, {.i64 = 10}, 0, INT_MAX, ENC},
{"rtmp_live", "Specify that the media is a live stream.", OFFSET(live), AV_OPT_TYPE_INT, {.i64 = -2}, INT_MIN, INT_MAX, DEC, "rtmp_live"},
{"any", "both", 0, AV_OPT_TYPE_CONST, {.i64 = -2}, 0, 0, DEC, "rtmp_live"},
{"live", "live stream", 0, AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0, DEC, "rtmp_live"},
{"recorded", "recorded stream", 0, AV_OPT_TYPE_CONST, {.i64 = 0}, 0, 0, DEC, "rtmp_live"},
{"rtmp_pageurl", "URL of the web page in which the media was embedded. By default no value will be sent.", OFFSET(pageurl), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC},
{"rtmp_playpath", "Stream identifier to play or to publish", OFFSET(playpath), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
{"rtmp_subscribe", "Name of live stream to subscribe to. Defaults to rtmp_playpath.", OFFSET(subscribe), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC},
{"rtmp_swfhash", "SHA256 hash of the decompressed SWF file (32 bytes).", OFFSET(swfhash), AV_OPT_TYPE_BINARY, .flags = DEC},
{"rtmp_swfsize", "Size of the decompressed SWF file, required for SWFVerification.", OFFSET(swfsize), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, DEC},
{"rtmp_swfurl", "URL of the SWF player. By default no value will be sent", OFFSET(swfurl), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
{"rtmp_swfverify", "URL to player swf file, compute hash/size automatically.", OFFSET(swfverify), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC},
{"rtmp_tcurl", "URL of the target stream. Defaults to proto://host[:port]/app.", OFFSET(tcurl), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
{"rtmp_listen", "Listen for incoming rtmp connections", OFFSET(listen), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, DEC, "rtmp_listen" },
{"listen", "Listen for incoming rtmp connections", OFFSET(listen), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, DEC, "rtmp_listen" },
{"tcp_nodelay", "Use TCP_NODELAY to disable Nagle's algorithm", OFFSET(tcp_nodelay), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, DEC|ENC},
{"timeout", "Maximum timeout (in seconds) to wait for incoming connections. -1 is infinite. Implies -rtmp_listen 1", OFFSET(listen_timeout), AV_OPT_TYPE_INT, {.i64 = -1}, INT_MIN, INT_MAX, DEC, "rtmp_listen" },
{ NULL },
}

Definition at line 3097 of file rtmpproto.c.

URL_PROTOCOL_FLAG_NETWORK
#define URL_PROTOCOL_FLAG_NETWORK
Definition: url.h:34
rtmp_close
static int rtmp_close(URLContext *h)
Definition: rtmpproto.c:2491
URLProtocol
Definition: url.h:54
AV_OPT_TYPE_BINARY
@ AV_OPT_TYPE_BINARY
offset must point to a pointer immediately followed by an int for the length
Definition: opt.h:230
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
RTMPContext
protocol handler context
Definition: rtmpproto.c:75
DEC
#define DEC
Definition: rtmpproto.c:3094
rtmp_write
static int rtmp_write(URLContext *s, const uint8_t *buf, int size)
Definition: rtmpproto.c:2952
URLProtocol::name
const char * name
Definition: url.h:55
rtmp_open
static int rtmp_open(URLContext *s, const char *uri, int flags, AVDictionary **opts)
Open RTMP connection and verify that the stream can be played.
Definition: rtmpproto.c:2590
rtmp_options
static const AVOption rtmp_options[]
Definition: rtmpproto.c:3097
ENC
#define ENC
Definition: rtmpproto.c:3095
rtmp_seek
static int64_t rtmp_seek(URLContext *s, int stream_index, int64_t timestamp, int flags)
Definition: rtmpproto.c:2918
OFFSET
#define OFFSET(x)
Definition: rtmpproto.c:3093
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:71
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
rtmp_pause
static int rtmp_pause(URLContext *s, int pause)
Definition: rtmpproto.c:2938
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:228
rtmp_read
static int rtmp_read(URLContext *s, uint8_t *buf, int size)
Definition: rtmpproto.c:2891
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:233