* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+#include "libavutil/common.h"
+#include "libavcodec/mpegaudio.h"
#include "avformat.h"
#include "riff.h"
-#include "mpegaudio.h"
#include "asf.h"
-#include "common.h"
#include "asfcrypt.h"
extern void ff_mms_set_stream_selection(URLContext *h, AVFormatContext *format);
static void get_guid(ByteIOContext *s, GUID *g)
{
assert(sizeof(*g) == 16);
- get_buffer(s, g, sizeof(*g));
+ get_buffer(s, *g, sizeof(*g));
}
#if 0
}
#endif
-static int is_mms(ByteIOContext *pb)
-{
- return url_fileno(pb) && url_fileno(pb)->prot &&
- !strcmp(url_fileno(pb)->prot->name, "mmsh");
-}
-
static void get_str16_nolen(ByteIOContext *pb, int len, char *buf, int buf_size)
{
char* q = buf;
get_guid(pb, &g);
if (memcmp(&g, &asf_header, sizeof(GUID)))
- goto fail;
+ return -1;
get_le64(pb);
get_le32(pb);
get_byte(pb);
break;
}
if (gsize < 24)
- goto fail;
+ return -1;
if (!memcmp(&g, &file_header, sizeof(GUID))) {
get_guid(pb, &asf->hdr.guid);
asf->hdr.file_size = get_le64(pb);
asf->hdr.create_time = get_le64(pb);
asf->nb_packets = get_le64(pb);
- asf->hdr.send_time = get_le64(pb);
asf->hdr.play_time = get_le64(pb);
+ asf->hdr.send_time = get_le64(pb);
asf->hdr.preroll = get_le32(pb);
asf->hdr.ignore = get_le32(pb);
asf->hdr.flags = get_le32(pb);
st = av_new_stream(s, 0);
if (!st)
- goto fail;
+ return AVERROR(ENOMEM);
av_set_pts_info(st, 32, 1, 1000); /* 32 bit pts in ms */
asf_st = av_mallocz(sizeof(ASFStream));
if (!asf_st)
- goto fail;
+ return AVERROR(ENOMEM);
st->priv_data = asf_st;
start_time = asf->hdr.preroll;
} else if (!memcmp(&g, &video_stream, sizeof(GUID))) {
type = CODEC_TYPE_VIDEO;
} else if (!memcmp(&g, &command_stream, sizeof(GUID))) {
- type = CODEC_TYPE_UNKNOWN;
+ type = CODEC_TYPE_DATA;
} else if (!memcmp(&g, &ext_stream_embed_stream_header, sizeof(GUID))) {
test_for_ext_stream_audio = 1;
type = CODEC_TYPE_UNKNOWN;
} else {
- goto fail;
+ return -1;
}
get_guid(pb, &g);
total_size = get_le64(pb);
if (is_dvr_ms_audio) {
// codec_id and codec_tag are unreliable in dvr_ms
// files. Set them later by probing stream.
- st->codec->codec_id = CODEC_ID_NONE;
+ st->codec->codec_id = CODEC_ID_PROBE;
st->codec->codec_tag = 0;
}
st->need_parsing = AVSTREAM_PARSE_FULL;
get_str16_nolen(pb, name_len, name, sizeof(name));
value_type = get_le16(pb);
value_len = get_le16(pb);
- if ((value_type == 0) || (value_type == 1)) // unicode or byte
+ if (value_type <= 1) // unicode or byte
{
if (!strcmp(name,"WM/AlbumTitle")) get_str16_nolen(pb, value_len, s->album, sizeof(s->album));
else if(!strcmp(name,"WM/Genre" )) get_str16_nolen(pb, value_len, s->genre, sizeof(s->genre));
}
else url_fskip(pb, value_len);
}
- if ((value_type >= 2) && (value_type <= 5)) // boolean or DWORD or QWORD or WORD
+ else if (value_type <= 5) // boolean or DWORD or QWORD or WORD
{
value_num= get_value(pb, value_type);
if (!strcmp(name,"WM/Track" ) && s->track == 0) s->track = value_num + 1;
if (!strcmp(name,"WM/TrackNumber")) s->track = value_num;
- }
+ }else
+ url_fskip(pb, value_len);
}
} else if (!memcmp(&g, &metadata_header, sizeof(GUID))) {
int n, stream_num, name_len, value_len, value_type, value_num;
}
#endif
} else if (url_feof(pb)) {
- goto fail;
+ return -1;
} else {
url_fseek(pb, gsize - 24, SEEK_CUR);
}
get_byte(pb);
get_byte(pb);
if (url_feof(pb))
- goto fail;
+ return -1;
asf->data_offset = url_ftell(pb);
asf->packet_size_left = 0;
}
}
-#ifdef CONFIG_MMSH_PROTOCOL
- /* Give info about ourselves to the mms protocol */
- if(is_mms(pb))
- ff_mms_set_stream_selection(url_fileno(pb), s);
-#endif
-
return 0;
-
- fail:
- for(i=0;i<s->nb_streams;i++) {
- AVStream *st = s->streams[i];
- if (st) {
- av_free(st->priv_data);
- av_free(st->codec->extradata);
- }
- av_free(st);
- }
- return -1;
}
#define DO_2BITS(bits, var, defval) \
asf_reset_header(s);
for(i=0;i<s->nb_streams;i++) {
AVStream *st = s->streams[i];
- av_free(st->priv_data);
av_free(st->codec->palctrl);
}
return 0;
AVInputFormat asf_demuxer = {
"asf",
- "asf format",
+ NULL_IF_CONFIG_SMALL("ASF format"),
sizeof(ASFContext),
asf_probe,
asf_read_header,