rtmp_amf_flv.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * rtmp_amf_flv.h: RTMP, AMF and FLV over RTMP implementation.
00003  *****************************************************************************
00004  * Copyright (C) URJC - LADyR - Luis Lopez Fernandez
00005  *
00006  * Author: Miguel Angel Cabrera Moya
00007  *
00008  * This program is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00021  *****************************************************************************/
00022 
00023 /*****************************************************************************
00024  * Local prototypes (continued from access.c)
00025  *****************************************************************************/
00026 typedef struct rtmp_packet_t rtmp_packet_t;
00027 typedef struct rtmp_body_t rtmp_body_t;
00028 typedef struct rtmp_control_thread_t rtmp_control_thread_t;
00029 typedef void (*rtmp_handler_t)( rtmp_control_thread_t *p_thread, rtmp_packet_t *rtmp_packet );
00030 
00031 struct rtmp_packet_t
00032 {
00033     int length_header;
00034     int stream_index;
00035     uint32_t timestamp;
00036     uint32_t timestamp_relative;
00037     int32_t length_encoded;
00038     int32_t length_body;
00039     uint8_t content_type;
00040     uint32_t src_dst;
00041     rtmp_body_t *body;
00042 };
00043 
00044 struct rtmp_body_t
00045 {
00046     int32_t length_body; /* without interchunk headers */
00047     int32_t length_buffer;
00048     uint8_t *body;
00049 };
00050 
00051 struct rtmp_control_thread_t
00052 {
00053     VLC_COMMON_MEMBERS
00054 
00055     int fd;
00056     bool b_error;
00057 
00058     vlc_url_t url;
00059     char *psz_application;
00060     char *psz_media;
00061 
00062     char *psz_swf_url;
00063     char *psz_page_url;
00064 
00065     block_fifo_t *p_fifo_input;
00066     block_fifo_t *p_empty_blocks;
00067 
00068     vlc_mutex_t lock;
00069     vlc_cond_t  wait;
00070     vlc_thread_t thread;
00071 
00072     int result_connect;
00073     int result_publish;
00074     int result_play;
00075     int result_stop;
00076 
00077     double stream_client_id;
00078     double stream_server_id;
00079 
00080     char *psz_publish;
00081 
00082     /* Rebuild FLV variables (access) */
00083     int has_audio;
00084     int has_video;
00085     int metadata_received;
00086     uint8_t metadata_stereo;
00087     uint8_t metadata_samplesize;
00088     uint32_t metadata_samplerate;
00089     uint8_t metadata_audiocodecid;
00090     uint8_t metadata_videocodecid;
00091     uint8_t metadata_frametype;
00092     int first_media_packet;
00093     uint32_t flv_tag_previous_tag_size;
00094 
00095     /* Vars for rebuilding FLV (access_output) */
00096     rtmp_body_t *flv_body;
00097     uint8_t flv_content_type;
00098     uint32_t flv_length_body;
00099     uint32_t flv_timestamp;
00100 
00101     /* vars for channel state */
00102     uint32_t chunk_size_recv;
00103     uint32_t chunk_size_send;
00104     rtmp_packet_t rtmp_headers_recv[64]; /* RTMP_HEADER_STREAM_MAX */
00105     rtmp_packet_t rtmp_headers_send[64];
00106 
00107     rtmp_handler_t rtmp_handler[21]; /* index by RTMP_CONTENT_TYPE */
00108 
00109     /* Pointer to base module object (later needs to casted) */
00110     void *p_base_object;
00111 };
00112 
00113 struct access_sys_t
00114 {
00115     int active;
00116 
00117     /* vars for reading from fifo */
00118     block_t *flv_packet;
00119     int read_packet;
00120 
00121     /* thread for filtering and handling control messages */
00122     rtmp_control_thread_t *p_thread;
00123 };
00124 
00125 /*****************************************************************************
00126  * RTMP header:
00127  ******************************************************************************/
00128 int rtmp_handshake_active( vlc_object_t *p_this, int fd );
00129 int rtmp_handshake_passive( vlc_object_t *p_this, int fd );
00130 int rtmp_connect_active( rtmp_control_thread_t *p_thread );
00131 int rtmp_connect_passive( rtmp_control_thread_t *p_thread );
00132 //int rtmp_seek( access_t *p_access, int64_t i_pos ); TODO
00133 //
00134 rtmp_packet_t *rtmp_build_bytes_read( rtmp_control_thread_t *p_thread, uint32_t reply );
00135 rtmp_packet_t *rtmp_build_publish_start( rtmp_control_thread_t *p_thread );
00136 rtmp_packet_t *rtmp_build_flv_over_rtmp( rtmp_control_thread_t *p_thread, block_t *p_buffer );
00137 
00138 rtmp_packet_t *rtmp_read_net_packet( rtmp_control_thread_t *p_thread );
00139 uint8_t *rtmp_encode_packet( rtmp_control_thread_t *p_thread, rtmp_packet_t *rtmp_packet );
00140 void rtmp_init_handler( rtmp_handler_t *rtmp_handler );
00141 /*****************************************************************************
00142  * FLV header:
00143  ******************************************************************************/
00144 block_t *flv_get_metadata( access_t *p_access );
00145 block_t *flv_insert_header( access_t *p_access, block_t *first_packet );
00146 
00147 /*****************************************************************************
00148  * RTMP body header:
00149  ******************************************************************************/
00150 rtmp_body_t *rtmp_body_new( int length_buffer );
00151 void rtmp_body_reset( rtmp_body_t * );

Generated on Tue May 25 08:04:52 2010 for VLC by  doxygen 1.5.6