]> git.sesse.net Git - vlc/blob - modules/access/mms/mms.h
5bd6b5cbde8a97cbcc6fa45262c396a63b98b3d8
[vlc] / modules / access / mms / mms.h
1 /*****************************************************************************
2  * mms.h: MMS access plug-in
3  *****************************************************************************
4  * Copyright (C) 2001, 2002 VideoLAN
5  * $Id: mms.h,v 1.5 2002/11/25 15:08:34 fenrir Exp $
6  *
7  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  * 
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 /* url: [/]host[:port][/path] */
25 typedef struct url_s
26 {
27     char    *psz_server_addr;
28     int     i_server_port;
29
30     char    *psz_bind_addr;
31     int     i_bind_port;
32     
33     char    *psz_path;
34
35     /* private */
36     char *psz_private;
37 } url_t;
38
39 #define FREE( p ) if( p ) free( p )
40
41
42 #define MMS_PROTO_AUTO  0
43 #define MMS_PROTO_TCP   1
44 #define MMS_PROTO_UDP   2
45
46 #define MMS_PACKET_ANY          0
47 #define MMS_PACKET_CMD          1
48 #define MMS_PACKET_HEADER       2
49 #define MMS_PACKET_MEDIA        3
50 #define MMS_PACKET_UDP_TIMING   4
51     
52
53 #define MMS_STREAM_VIDEO    0x0001
54 #define MMS_STREAM_AUDIO    0x0002
55 #define MMS_STREAM_UNKNOWN  0xffff
56
57
58 #define MMS_CMD_HEADERSIZE  48
59
60 typedef struct mms_stream_s
61 {
62     int i_id;       /* 1 -> 127 */
63     int i_cat;      /* MMS_STREAM_VIDEO, MMS_STREAM_AUDIO */
64     int i_bitrate;  /* -1 if unknown */
65     int i_selected;
66     
67 } mms_stream_t;
68
69 #define MMS_BUFFER_SIZE 100000
70 typedef struct access_s
71 {
72     int                 i_proto;        /* MMS_PROTO_TCP, MMS_PROTO_UDP */
73     input_socket_t      socket_tcp;     /* TCP socket for communication with server */
74     input_socket_t      socket_udp;     /* Optional UDP socket for data(media/header packet) */
75                                         /* send by server */
76     char                *psz_bind_addr; /* used by udp */
77
78     url_t   url;                        /* connect to this server */
79     
80     mms_stream_t        stream[128];    /* in asf never more than 1->127 streams */
81     
82     off_t               i_pos;          /* position of next byte to be read */
83     
84     /* */
85     uint8_t             buffer_tcp[MMS_BUFFER_SIZE];
86     int                 i_buffer_tcp;
87     
88     uint8_t             buffer_udp[MMS_BUFFER_SIZE];
89     int                 i_buffer_udp;
90
91     /* data necessary to send data to server */
92     guid_t      guid;
93     int         i_command_level;
94     int         i_seq_num;
95     uint32_t    i_header_packet_id_type;
96     uint32_t    i_media_packet_id_type;
97
98     int         i_packet_seq_num;
99     
100     uint8_t     *p_cmd;     /* latest command read */
101     int         i_cmd;      /* allocated at the begining */
102
103     uint8_t     *p_header;  /* allocated by mms_ReadPacket */
104     int         i_header;
105     
106     uint8_t     *p_media;   /* allocated by mms_ReadPacket */
107     int         i_media;
108     int         i_media_used;
109     
110     /* extracted informations */
111     int         i_command;
112     int         i_eos;
113
114     /* from 0x01 answer (not yet set) */
115     char        *psz_server_version;
116     char        *psz_tool_version;
117     char        *psz_update_player_url;
118     char        *psz_encryption_type;
119
120     /* from 0x06 answer */
121     uint32_t    i_flags_broadcast;
122     uint32_t    i_media_length;
123     int         i_packet_length;
124     uint32_t    i_packet_count;
125     int         i_max_bit_rate;
126     int         i_header_size;
127     
128 } access_t;
129
130
131 static inline uint16_t GetWLE( u8 *p_buff )
132 {
133     return( (p_buff[0]) + ( p_buff[1] <<8 ) );
134 }
135
136 static inline uint32_t GetDWLE( u8 *p_buff )
137 {
138     return( p_buff[0] + ( p_buff[1] <<8 ) +
139             ( p_buff[2] <<16 ) + ( p_buff[3] <<24 ) );
140 }
141