]> git.sesse.net Git - vlc/blob - modules/access/rtmp/rtmp_amf_flv.h
block_FifoNew: remove un-needed parameter
[vlc] / modules / access / rtmp / rtmp_amf_flv.h
1 /*****************************************************************************
2  * rtmp_amf_flv.h: RTMP, AMF and FLV over RTMP implementation.
3  *****************************************************************************
4  * Copyright (C) URJC - LADyR - Luis Lopez Fernandez
5  *
6  * Author: Miguel Angel Cabrera Moya
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21  *****************************************************************************/
22
23 /*****************************************************************************
24  * Local prototypes (continued from access.c)
25  *****************************************************************************/
26 typedef struct rtmp_packet_t rtmp_packet_t;
27 typedef struct rtmp_body_t rtmp_body_t;
28 typedef struct rtmp_control_thread_t rtmp_control_thread_t;
29 typedef void (*rtmp_handler_t)( rtmp_control_thread_t *rtmp_control_thread, rtmp_packet_t *rtmp_packet );
30
31 struct rtmp_packet_t
32 {
33     int length_header;
34     int stream_index;
35     uint32_t timestamp;
36     uint32_t timestamp_relative;
37     int32_t length_encoded;
38     int32_t length_body;
39     uint8_t content_type;
40     uint32_t src_dst;
41     rtmp_body_t *body;
42 };
43
44 struct rtmp_body_t
45 {
46     int32_t length_body; /* without interchunk headers */
47     int32_t length_buffer;
48     uint8_t *body;
49 };
50
51 struct rtmp_control_thread_t
52 {
53     VLC_COMMON_MEMBERS
54
55     int fd;
56
57     block_fifo_t *p_fifo_media;
58     block_fifo_t *p_empty_blocks;
59
60     vlc_mutex_t lock;
61     vlc_cond_t  wait;
62
63     int result_connect;
64     int result_play;
65     int result_publish;
66
67     double stream_client;
68     double stream_server;
69
70     char *psz_publish;
71
72     /* Rebuild FLV variables */
73     int has_audio;
74     int has_video;
75     int metadata_received;
76     uint8_t metadata_stereo;
77     uint8_t metadata_samplesize;
78     uint8_t metadata_samplerate;
79     uint8_t metadata_audiocodecid;
80     uint8_t metadata_videocodecid;
81     uint8_t metadata_frametype;
82     int first_media_packet;
83     uint32_t flv_tag_previous_tag_size;
84
85     /* vars for channel state */
86     rtmp_packet_t rtmp_headers_recv[64]; /* RTMP_HEADER_STREAM_MAX */
87     rtmp_packet_t rtmp_headers_send[64];
88
89     rtmp_handler_t rtmp_handler[21]; /* index by RTMP_CONTENT_TYPE */
90 };
91
92 struct access_sys_t
93 {
94     int active;
95
96     int fd;
97
98     vlc_url_t url;
99     char *psz_application;
100     char *psz_media;
101
102     /* vars for reading from fifo */
103     block_t *flv_packet;
104     int read_packet;
105
106     /* thread for filtering and handling control messages */
107     rtmp_control_thread_t *p_thread;
108 };
109
110 /*****************************************************************************
111  * RTMP header:
112  ******************************************************************************/
113 int rtmp_handshake_passive( vlc_object_t *p_this );
114 int rtmp_handshake_active( vlc_object_t *p_this );
115 int rtmp_connect_active( vlc_object_t *p_this );
116 //int rtmp_seek( access_t *p_access, int64_t i_pos ); TODO
117 int rtmp_send_bytes_read( access_t *p_access, uint32_t reply );
118 int rtmp_send_publish_start( access_t *p_access );
119
120 rtmp_packet_t *rtmp_read_net_packet( rtmp_control_thread_t *p_thread );
121 void rtmp_init_handler( rtmp_handler_t *rtmp_handler );
122 /*****************************************************************************
123  * FLV header:
124  ******************************************************************************/
125 block_t *flv_get_metadata( access_t *p_access );
126 block_t *flv_insert_header( access_t *p_access, block_t *first_packet );