1 /* ASF muxer plugin for GStreamer
2 * Copyright (C) 2009 Thiago Santos <thiagoss@embedded.ufcg.edu.br>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
19 #ifndef __GST_ASF_OBJECTS_H__
20 #define __GST_ASF_OBJECTS_H__
24 #include <gst/base/gstbytereader.h>
25 #include <gst/base/gstcollectpads.h>
27 #define ASF_PAYLOAD_IS_KEYFRAME(pay) ((pay->stream_number & 0x80) != 0)
28 #define ASF_MILI_TO_100NANO(v) (v * 10000)
29 #define ASF_GUID_SIZE 16
30 #define ASF_GUID_OBJSIZE_SIZE 24
40 typedef struct _GstAsfFileInfo
42 guint64 packets_count;
47 typedef struct _GstAsfPacketInfo
50 gboolean multiple_payloads;
51 guint8 padd_field_type;
52 guint8 packet_field_type;
53 guint8 seq_field_type;
59 gboolean has_keyframe;
62 typedef struct _SimpleIndexEntry
64 guint32 packet_number;
68 typedef struct _AsfPayload
72 guint32 offset_in_media_obj;
73 guint8 replicated_data_length;
74 guint32 media_object_size;
75 guint32 presentation_time;
80 /* simple index info */
81 gboolean has_packet_info;
82 guint32 packet_number;
86 void gst_asf_generate_file_id (Guid *guid);
88 gboolean gst_byte_reader_get_asf_var_size_field (GstByteReader * reader,
89 guint8 field_type, guint32 * var);
90 guint32 gst_asf_read_var_size_field (guint8 * data, guint8 field_type);
91 guint gst_asf_get_var_size_field_len (guint8 field_type);
93 GstAsfFileInfo *gst_asf_file_info_new (void);
94 void gst_asf_file_info_reset (GstAsfFileInfo * info);
95 void gst_asf_file_info_free (GstAsfFileInfo * info);
97 guint32 gst_asf_payload_get_size (AsfPayload * payload);
98 void gst_asf_payload_free (AsfPayload * payload);
100 guint64 gst_asf_get_current_time (void);
102 gboolean gst_asf_match_guid (const guint8 * data, const Guid * g);
104 void gst_asf_put_i32 (guint8 * buf, gint32 data);
105 void gst_asf_put_time (guint8 * buf, guint64 time);
106 void gst_asf_put_guid (guint8 * buf, Guid guid);
107 void gst_asf_put_payload (guint8 * buf, AsfPayload * payload);
108 guint16 gst_asf_put_subpayload (guint8 * buf, AsfPayload * payload,
111 gboolean gst_asf_parse_packet (GstBuffer * buffer, GstAsfPacketInfo * packet,
112 gboolean trust_delta_flag, guint packet_size);
113 gboolean gst_asf_parse_packet_from_data (guint8 * data, gsize size, GstBuffer * buffer, GstAsfPacketInfo * packet,
114 gboolean trust_delta_flag, guint packet_size);
115 guint64 gst_asf_match_and_peek_obj_size (const guint8 * data,
117 guint64 gst_asf_match_and_peek_obj_size_buf (GstBuffer * buf,
119 gboolean gst_asf_parse_headers (GstBuffer * buffer, GstAsfFileInfo * file_info);
120 gboolean gst_asf_parse_headers_from_data (guint8 * data, guint size, GstAsfFileInfo * file_info);
123 * found at http://msdn.microsoft.com/en-us/library/dd562330(VS.85).aspx
126 #define ASF_TAG_TITLE "Title\0"
127 #define ASF_TAG_TITLE_SORTNAME "TitleSortOrder\0"
129 /* FIXME asf has no artist tag other than AlbumArtist, but it has Author
130 * What to use here? */
131 #define ASF_TAG_ARTIST "WM/AlbumArtist\0"
132 #define ASF_TAG_ARTIST_SORTNAME "AlbumArtistSortOrder\0"
134 #define ASF_TAG_ALBUM_TITLE "WM/AlbumTitle\0"
135 #define ASF_TAG_ALBUM_TITLE_SORTNAME "AlbumTitleSortOrder\0"
137 #define ASF_TAG_GENRE "WM/Genre\0"
138 #define ASF_TAG_COMMENT "Comment\0"
139 #define ASF_TAG_TRACK_NUMBER "WM/TrackNumber\0"
140 #define ASF_TAG_COPYRIGHT "Copyright\0"
141 #define ASF_TAG_COMPOSER "WM/Composer\0"
143 const gchar *gst_asf_get_asf_tag (const gchar * gsttag);
144 guint gst_asf_get_tag_field_type (GValue * value);
145 gboolean gst_asf_tag_present_in_content_description (const gchar * tag);
147 /* ASF Objects Sizes */
148 #define ASF_HEADER_OBJECT_SIZE 30
149 #define ASF_FILE_PROPERTIES_OBJECT_SIZE 104
150 #define ASF_STREAM_PROPERTIES_OBJECT_SIZE 78
151 #define ASF_HEADER_EXTENSION_OBJECT_SIZE 46
152 #define ASF_AUDIO_SPECIFIC_DATA_SIZE 18
153 #define ASF_VIDEO_SPECIFIC_DATA_SIZE 51
154 #define ASF_DATA_OBJECT_SIZE 50
155 #define ASF_SINGLE_PAYLOAD_HEADER_SIZE 15
156 #define ASF_MULTIPLE_PAYLOAD_HEADER_SIZE 17
157 #define ASF_EXTENDED_STREAM_PROPERTIES_OBJECT_SIZE 88
158 #define ASF_CONTENT_DESCRIPTION_OBJECT_SIZE 34
159 #define ASF_EXT_CONTENT_DESCRIPTION_OBJECT_SIZE 26
160 #define ASF_SIMPLE_INDEX_OBJECT_SIZE 56
161 #define ASF_SIMPLE_INDEX_ENTRY_SIZE 6
162 #define ASF_METADATA_OBJECT_SIZE 26
163 #define ASF_PADDING_OBJECT_SIZE 24
165 /* Field types for data object payload description */
166 #define ASF_FIELD_TYPE_NONE 0
167 #define ASF_FIELD_TYPE_BYTE 1
168 #define ASF_FIELD_TYPE_WORD 2
169 #define ASF_FIELD_TYPE_DWORD 3
170 #define ASF_FIELD_TYPE_MASK 3
173 #define ASF_TAG_TYPE_UNICODE_STR 0
174 #define ASF_TAG_TYPE_BYTES 1
175 #define ASF_TAG_TYPE_BOOL 2
176 #define ASF_TAG_TYPE_DWORD 3
177 #define ASF_TAG_TYPE_QWORD 4
178 #define ASF_TAG_TYPE_WORD 5
182 #define ASF_HEADER_OBJECT_INDEX 0
183 #define ASF_FILE_PROPERTIES_OBJECT_INDEX 1
184 #define ASF_STREAM_PROPERTIES_OBJECT_INDEX 2
185 #define ASF_AUDIO_MEDIA_INDEX 3
186 #define ASF_NO_ERROR_CORRECTION_INDEX 4
187 #define ASF_AUDIO_SPREAD_INDEX 5
188 #define ASF_HEADER_EXTENSION_OBJECT_INDEX 6
189 #define ASF_RESERVED_1_INDEX 7
190 #define ASF_DATA_OBJECT_INDEX 8
191 #define ASF_EXTENDED_STREAM_PROPERTIES_OBJECT_INDEX 9
192 #define ASF_VIDEO_MEDIA_INDEX 10
193 #define ASF_SIMPLE_INDEX_OBJECT_INDEX 11
194 #define ASF_CONTENT_DESCRIPTION_INDEX 12
195 #define ASF_EXT_CONTENT_DESCRIPTION_INDEX 13
196 #define ASF_METADATA_OBJECT_INDEX 14
197 #define ASF_PADDING_OBJECT_INDEX 15
199 extern const Guid guids[];