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 00057 vlc_url_t url; 00058 char *psz_application; 00059 char *psz_media; 00060 00061 block_fifo_t *p_fifo_input; 00062 block_fifo_t *p_empty_blocks; 00063 00064 vlc_mutex_t lock; 00065 vlc_cond_t wait; 00066 00067 int result_connect; 00068 int result_publish; 00069 int result_play; 00070 int result_stop; 00071 00072 double stream_client_id; 00073 double stream_server_id; 00074 00075 char *psz_publish; 00076 00077 /* Rebuild FLV variables (access) */ 00078 int has_audio; 00079 int has_video; 00080 int metadata_received; 00081 uint8_t metadata_stereo; 00082 uint8_t metadata_samplesize; 00083 uint32_t metadata_samplerate; 00084 uint8_t metadata_audiocodecid; 00085 uint8_t metadata_videocodecid; 00086 uint8_t metadata_frametype; 00087 int first_media_packet; 00088 uint32_t flv_tag_previous_tag_size; 00089 00090 /* Vars for rebuilding FLV (access_output) */ 00091 rtmp_body_t *flv_body; 00092 uint8_t flv_content_type; 00093 uint32_t flv_length_body; 00094 uint32_t flv_timestamp; 00095 00096 /* vars for channel state */ 00097 uint32_t chunk_size_recv; 00098 uint32_t chunk_size_send; 00099 rtmp_packet_t rtmp_headers_recv[64]; /* RTMP_HEADER_STREAM_MAX */ 00100 rtmp_packet_t rtmp_headers_send[64]; 00101 00102 rtmp_handler_t rtmp_handler[21]; /* index by RTMP_CONTENT_TYPE */ 00103 00104 /* Pointer to base module object (later needs to casted) */ 00105 void *p_base_object; 00106 }; 00107 00108 struct access_sys_t 00109 { 00110 int active; 00111 00112 /* vars for reading from fifo */ 00113 block_t *flv_packet; 00114 int read_packet; 00115 00116 /* thread for filtering and handling control messages */ 00117 rtmp_control_thread_t *p_thread; 00118 }; 00119 00120 /***************************************************************************** 00121 * RTMP header: 00122 ******************************************************************************/ 00123 int rtmp_handshake_active( vlc_object_t *p_this, int fd ); 00124 int rtmp_handshake_passive( vlc_object_t *p_this, int fd ); 00125 int rtmp_connect_active( rtmp_control_thread_t *p_thread ); 00126 int rtmp_connect_passive( rtmp_control_thread_t *p_thread ); 00127 //int rtmp_seek( access_t *p_access, int64_t i_pos ); TODO 00128 // 00129 rtmp_packet_t *rtmp_build_bytes_read( rtmp_control_thread_t *p_thread, uint32_t reply ); 00130 rtmp_packet_t *rtmp_build_publish_start( rtmp_control_thread_t *p_thread ); 00131 rtmp_packet_t *rtmp_build_flv_over_rtmp( rtmp_control_thread_t *p_thread, block_t *p_buffer ); 00132 00133 rtmp_packet_t *rtmp_read_net_packet( rtmp_control_thread_t *p_thread ); 00134 uint8_t *rtmp_encode_packet( rtmp_control_thread_t *p_thread, rtmp_packet_t *rtmp_packet ); 00135 void rtmp_init_handler( rtmp_handler_t *rtmp_handler ); 00136 /***************************************************************************** 00137 * FLV header: 00138 ******************************************************************************/ 00139 block_t *flv_get_metadata( access_t *p_access ); 00140 block_t *flv_insert_header( access_t *p_access, block_t *first_packet ); 00141 00142 /***************************************************************************** 00143 * RTMP body header: 00144 ******************************************************************************/ 00145 rtmp_body_t *rtmp_body_new( int length_buffer ); 00146 void rtmp_body_reset( rtmp_body_t * );
1.5.1