FFmpeg
|
RTMP protocol. More...
#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 "libavutil/sha.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 | PLAYPATH_MAX_LENGTH 256 |
#define | TCURL_MAX_LENGTH 512 |
#define | FLASHVER_MAX_LENGTH 64 |
#define | RTMP_PKTDATA_DEFAULT_SIZE 4096 |
#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 | OFFSET(x) offsetof(RTMPContext, x) |
#define | DEC AV_OPT_FLAG_DECODING_PARAM |
#define | ENC AV_OPT_FLAG_ENCODING_PARAM |
#define | RTMP_PROTOCOL(flavor) |
Typedefs | |
typedef struct TrackedMethod | TrackedMethod |
typedef struct RTMPContext | RTMPContext |
protocol handler context More... | |
Enumerations | |
enum | ClientState { STATE_START, STATE_HANDSHAKED, STATE_FCPUBLISH, STATE_PLAYING, STATE_PUBLISHING, STATE_RECEIVING, STATE_STOPPED } |
RTMP protocol handler state. More... | |
Functions | |
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_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_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_server_bw (URLContext *s, RTMPContext *rt) |
Generate server bandwidth 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) |
int | ff_rtmp_calc_digest (const uint8_t *src, int len, int gap, const uint8_t *key, int keylen, uint8_t *dst) |
Calculate HMAC-SHA2 digest for RTMP handshake packets. More... | |
int | ff_rtmp_calc_digest_pos (const uint8_t *buf, int off, int mod_val, int add_val) |
Calculate digest position for RTMP handshake packets. More... | |
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_chunk_size (URLContext *s, RTMPPacket *pkt) |
static int | handle_ping (URLContext *s, RTMPPacket *pkt) |
static int | handle_client_bw (URLContext *s, RTMPPacket *pkt) |
static int | handle_server_bw (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 | send_invoke_response (URLContext *s, RTMPPacket *pkt) |
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 | 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 | 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 | rtmp_open (URLContext *s, const char *uri, int flags) |
Open RTMP connection and verify that the stream can be played. More... | |
static int | rtmp_read (URLContext *s, uint8_t *buf, int size) |
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
#define APP_MAX_LENGTH 1024 |
Definition at line 53 of file rtmpproto.c.
Referenced by gen_connect(), and rtmp_open().
#define DEC AV_OPT_FLAG_DECODING_PARAM |
Definition at line 2630 of file rtmpproto.c.
#define ENC AV_OPT_FLAG_ENCODING_PARAM |
Definition at line 2631 of file rtmpproto.c.
#define FLASHVER_MAX_LENGTH 64 |
Definition at line 56 of file rtmpproto.c.
Referenced by rtmp_open().
#define OFFSET | ( | x | ) | offsetof(RTMPContext, x) |
Definition at line 2629 of file rtmpproto.c.
#define PLAYER_KEY_OPEN_PART_LEN 30 |
length of partial key used for first client digest signing
Definition at line 128 of file rtmpproto.c.
Referenced by rtmp_handshake_imprint_with_digest().
#define PLAYPATH_MAX_LENGTH 256 |
Definition at line 54 of file rtmpproto.c.
Referenced by rtmp_open().
#define RTMP_PKTDATA_DEFAULT_SIZE 4096 |
Definition at line 57 of file rtmpproto.c.
Referenced by read_connect(), and send_invoke_response().
#define RTMP_PROTOCOL | ( | flavor | ) |
Definition at line 2656 of file rtmpproto.c.
#define SERVER_KEY_OPEN_PART_LEN 36 |
length of partial key used for first server digest signing
Definition at line 139 of file rtmpproto.c.
Referenced by rtmp_validate_digest().
#define TCURL_MAX_LENGTH 512 |
Definition at line 55 of file rtmpproto.c.
Referenced by rtmp_open().
Typedef Documentation
typedef struct RTMPContext RTMPContext |
protocol handler context
typedef struct TrackedMethod TrackedMethod |
Enumeration Type Documentation
enum ClientState |
RTMP protocol handler state.
Definition at line 60 of file rtmpproto.c.
Function Documentation
|
static |
Definition at line 151 of file rtmpproto.c.
Referenced by rtmp_send_packet().
|
static |
Definition at line 173 of file rtmpproto.c.
Referenced by find_tracked_method().
|
static |
Definition at line 1522 of file rtmpproto.c.
Referenced by handle_connect_error().
|
static |
Definition at line 1561 of file rtmpproto.c.
Referenced by handle_connect_error().
int ff_rtmp_calc_digest | ( | const uint8_t * | src, |
int | len, | ||
int | gap, | ||
const uint8_t * | key, | ||
int | keylen, | ||
uint8_t * | dst | ||
) |
Calculate HMAC-SHA2 digest for RTMP handshake packets.
- Parameters
-
src input buffer len input buffer length (should be 1536) gap offset in buffer where 32 bytes should not be taken into account when calculating digest (since it will be used to store that digest) key digest key keylen digest key length dst buffer where calculated digest will be stored (32 bytes)
Definition at line 862 of file rtmpproto.c.
Referenced by ff_rtmpe_compute_secret_key(), rtmp_calc_swf_verification(), rtmp_calc_swfhash(), rtmp_handshake(), rtmp_handshake_imprint_with_digest(), and rtmp_validate_digest().
int ff_rtmp_calc_digest_pos | ( | const uint8_t * | buf, |
int | off, | ||
int | mod_val, | ||
int | add_val | ||
) |
Calculate digest position for RTMP handshake packets.
- Parameters
-
buf input buffer (should be 1536 bytes) off offset in buffer where to start calculating digest position mod_val value used for computing modulo add_val value added at the end (after computing modulo)
Definition at line 904 of file rtmpproto.c.
Referenced by ff_rtmpe_compute_secret_key(), ff_rtmpe_gen_pub_key(), rtmp_handshake_imprint_with_digest(), and rtmp_validate_digest().
|
static |
Definition at line 180 of file rtmpproto.c.
Referenced by handle_invoke_error(), and handle_invoke_result().
|
static |
Definition at line 205 of file rtmpproto.c.
Referenced by rtmp_close(), and rtmp_open().
|
static |
Generate client buffer time and send it to the server.
Definition at line 663 of file rtmpproto.c.
Referenced by handle_invoke_result().
|
static |
Generate report on bytes read so far and send it to the server.
Definition at line 826 of file rtmpproto.c.
Referenced by get_packet().
|
static |
Generate check bandwidth message and send it to the server.
Definition at line 805 of file rtmpproto.c.
Referenced by handle_invoke().
|
static |
Generate 'connect' call and send it to the server.
Definition at line 308 of file rtmpproto.c.
Referenced by rtmp_open().
|
static |
Generate 'createStream' call and send it to the server.
It should make the server allocate some channel for media streams.
Definition at line 614 of file rtmpproto.c.
Referenced by handle_invoke_result().
|
static |
Generate 'deleteStream' call and send it to the server.
It should make the server remove some channel for media streams.
Definition at line 639 of file rtmpproto.c.
Referenced by rtmp_close().
|
static |
Generate 'FCPublish' call and send it to the server.
It should make the server preapare for receiving media streams.
Definition at line 566 of file rtmpproto.c.
Referenced by handle_invoke_result().
|
static |
Definition at line 842 of file rtmpproto.c.
Referenced by handle_invoke_result().
|
static |
Generate 'FCUnpublish' call and send it to the server.
It should make the server destroy stream.
Definition at line 590 of file rtmpproto.c.
Referenced by rtmp_close().
|
static |
Generate 'play' call and send it to the server, then ping the server to start actual playing.
Definition at line 685 of file rtmpproto.c.
Referenced by handle_invoke_result().
|
static |
Generate ping reply and send it to the server.
Definition at line 739 of file rtmpproto.c.
Referenced by handle_ping().
|
static |
Generate 'publish' call and send it to the server.
Definition at line 712 of file rtmpproto.c.
Referenced by handle_invoke_result().
|
static |
Generate 'releaseStream' call and send it to the server.
It should make the server release some channel for media streams.
Definition at line 542 of file rtmpproto.c.
Referenced by handle_invoke_result().
|
static |
Generate server bandwidth message and send it to the server.
Definition at line 786 of file rtmpproto.c.
Referenced by handle_invoke_result().
|
static |
Generate SWF verification message and send it to the server.
Definition at line 765 of file rtmpproto.c.
Referenced by handle_ping().
|
static |
Interact with the server by receiving and sending RTMP packets until there is some significant data (media data or expected status notification).
- Parameters
-
s reading context for_header non-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 2122 of file rtmpproto.c.
Referenced by ff_audio_rechunk_interleave(), rtmp_open(), and rtmp_read().
|
static |
Definition at line 1416 of file rtmpproto.c.
Referenced by rtmp_parse_result().
|
static |
Definition at line 1476 of file rtmpproto.c.
Referenced by rtmp_parse_result().
|
static |
Definition at line 1618 of file rtmpproto.c.
Referenced by handle_invoke_error().
|
static |
Definition at line 1969 of file rtmpproto.c.
Referenced by rtmp_parse_result().
|
static |
Definition at line 1704 of file rtmpproto.c.
Referenced by handle_invoke().
|
static |
Definition at line 1873 of file rtmpproto.c.
Referenced by handle_invoke().
|
static |
Definition at line 1937 of file rtmpproto.c.
Referenced by handle_invoke().
|
static |
Definition at line 1999 of file rtmpproto.c.
Referenced by get_packet().
|
static |
Definition at line 1449 of file rtmpproto.c.
Referenced by rtmp_parse_result().
|
static |
Definition at line 1500 of file rtmpproto.c.
Referenced by rtmp_parse_result().
|
static |
Definition at line 393 of file rtmpproto.c.
Referenced by rtmp_open().
|
static |
Definition at line 967 of file rtmpproto.c.
Referenced by rtmp_handshake().
|
static |
Definition at line 1035 of file rtmpproto.c.
Referenced by rtmp_open().
|
static |
Definition at line 2230 of file rtmpproto.c.
Referenced by rtmp_open().
|
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 1120 of file rtmpproto.c.
Referenced by rtmp_open().
|
static |
Put HMAC-SHA2 digest of packet data (except for the bytes where this digest will be stored) into that packet.
- Parameters
-
buf handshake data (1536 bytes) encrypted use an encrypted connection (RTMPE)
- Returns
- offset to the digest inside input data
Definition at line 924 of file rtmpproto.c.
Referenced by rtmp_handshake().
|
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 2260 of file rtmpproto.c.
|
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 2066 of file rtmpproto.c.
Referenced by get_packet(), and rtmp_write().
|
static |
Definition at line 2490 of file rtmpproto.c.
|
static |
Definition at line 1299 of file rtmpproto.c.
Referenced by rtmp_server_handshake().
|
static |
Definition at line 1320 of file rtmpproto.c.
Referenced by rtmp_server_handshake().
|
static |
Definition at line 217 of file rtmpproto.c.
Referenced by gen_buffer_time(), gen_bytes_read(), gen_check_bw(), gen_connect(), gen_create_stream(), gen_delete_stream(), gen_fcpublish_stream(), gen_fcsubscribe_stream(), gen_fcunpublish_stream(), gen_play(), gen_pong(), gen_publish(), gen_release_stream(), gen_server_bw(), gen_swf_verification(), and rtmp_write().
|
static |
|
static |
Verify that the received server response has the expected digest value.
- Parameters
-
buf handshake data received from the server (1536 bytes) off position to search digest offset from
- Returns
- 0 if digest is valid, digest position otherwise
Definition at line 949 of file rtmpproto.c.
Referenced by rtmp_handshake().
|
static |
Definition at line 2517 of file rtmpproto.c.
|
static |
Definition at line 245 of file rtmpproto.c.
Referenced by gen_connect().
|
static |
Definition at line 1740 of file rtmpproto.c.
Referenced by handle_invoke().
Variable Documentation
|
static |
Definition at line 2633 of file rtmpproto.c.
|
static |
Client key used for digest signing.
Definition at line 130 of file rtmpproto.c.
Referenced by rtmp_handshake(), and rtmp_handshake_imprint_with_digest().
|
static |
Key used for RTMP server digest signing.
Definition at line 141 of file rtmpproto.c.
Referenced by rtmp_handshake(), and rtmp_validate_digest().
Generated on Mon Nov 18 2024 06:52:08 for FFmpeg by 1.8.11