2
* The contents of this file are subject to the Mozilla Public
3
* License Version 1.1 (the "License"); you may not use this file
4
* except in compliance with the License. You may obtain a copy of
5
* the License at http://www.mozilla.org/MPL/
7
* Software distributed under the License is distributed on an "AS
8
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9
* implied. See the License for the specific language governing
10
* rights and limitations under the License.
12
* The Original Code is MPEG4IP.
14
* The Initial Developer of the Original Code is Cisco Systems Inc.
15
* Portions created by Cisco Systems Inc. are
16
* Copyright (C) Cisco Systems Inc. 2000, 2001. All Rights Reserved.
19
* Bill May wmay@cisco.com
22
* avi_file.cpp - provides generic class for avi file access control.
23
* file access is then used by avi audio and video bytestreams.
26
#include "player_session.h"
27
#include "player_media.h"
28
#include "player_util.h"
29
#include "media_utils.h"
30
#include "avi_bytestream.h"
32
#include "codec_plugin_private.h"
33
#include "our_config_file.h"
35
static void close_avi_file (void *data)
37
CAviFile *Avifile1 = (CAviFile *)data;
38
if (Avifile1 != NULL) {
45
* Create the media for the quicktime file, and set up some session stuff.
47
int create_media_for_avi_file (CPlayerSession *psptr,
49
int have_audio_driver,
50
control_callback_vft_t *cc_vft)
52
CAviFile *Avifile1 = NULL;
55
avi = AVI_open_input_file(name, 1);
57
psptr->set_message("%s", AVI_strerror());
58
player_error_message("%s", AVI_strerror());
63
codec_plugin_t *plugin;
66
const char *codec_name = AVI_video_compressor(avi);
67
player_debug_message("Trying avi video codec %s", codec_name);
68
plugin = check_for_video_codec(STREAM_TYPE_AVI_FILE,
80
vq.stream_type = STREAM_TYPE_AVI_FILE;
81
vq.compressor = codec_name;
85
vq.h = AVI_video_height(avi);
86
vq.w = AVI_video_width(avi);
87
vq.frame_rate = AVI_video_frame_rate(avi);
98
if (AVI_audio_bytes(avi) != 0) {
100
plugin = check_for_audio_codec(STREAM_TYPE_AVI_FILE,
103
AVI_audio_format(avi),
108
if (plugin != NULL) {
111
aq.stream_type = STREAM_TYPE_AVI_FILE;
112
aq.compressor = NULL;
113
aq.type = AVI_audio_format(avi);
116
aq.sampling_freq = AVI_audio_rate(avi);
117
aq.chans = AVI_audio_channels(avi);
125
if (cc_vft != NULL && cc_vft->media_list_query != NULL) {
126
(cc_vft->media_list_query)(psptr, video_count, &vq, audio_count, &aq,
129
if (video_count != 0) vq.enabled = 1;
130
if (audio_count != 0) aq.enabled = 1;
134
if ((video_count == 0 || vq.enabled == 0) &&
135
(audio_count == 0 || aq.enabled == 0)) {
136
psptr->set_message("No audio or video tracks enabled or playable");
141
Avifile1 = new CAviFile(name, avi, vq.enabled, audio_count);
142
psptr->set_media_close_callback(close_avi_file, Avifile1);
144
if (video_count != 0 && vq.enabled) {
145
mptr = new CPlayerMedia(psptr, VIDEO_SYNC);
150
video_info_t *vinfo = MALLOC_STRUCTURE(video_info_t);
153
vinfo->height = vq.h;
155
player_debug_message("avi file h %d w %d frame rate %g",
160
plugin = check_for_video_codec(STREAM_TYPE_AVI_FILE,
169
ret = mptr->create_video_plugin(plugin,
170
STREAM_TYPE_AVI_FILE,
179
psptr->set_message("Failed to create video plugin %s",
181
player_error_message("Failed to create plugin data");
185
CAviVideoByteStream *vbyte = new CAviVideoByteStream(Avifile1);
190
vbyte->config(AVI_video_frames(avi), vq.frame_rate);
191
ret = mptr->create_media("video", vbyte);
198
if (have_audio_driver > 0 && audio_count > 0 && aq.enabled != 0) {
199
plugin = check_for_audio_codec(STREAM_TYPE_AVI_FILE,
207
CAviAudioByteStream *abyte;
208
mptr = new CPlayerMedia(psptr, AUDIO_SYNC);
213
ainfo = MALLOC_STRUCTURE(audio_info_t);
214
ainfo->freq = aq.sampling_freq;
215
ainfo->chans = aq.chans;
216
ainfo->bitspersample = AVI_audio_bits(avi);
220
ret = mptr->create_audio_plugin(plugin,
231
player_error_message("Couldn't create audio from plugin %s",
235
abyte = new CAviAudioByteStream(Avifile1);
237
ret = mptr->create_media("audio", abyte);
243
psptr->session_set_seekable(seekable);
245
if (audio_count == 0 && have_audio != 0) {
246
psptr->set_message("Unknown Audio Codec in avi file ");
249
if (video_count != 1) {
250
psptr->set_message("Unknown Video Codec %s in avi file",
257
CAviFile::CAviFile (const char *name, avi_t *avi,
260
m_name = strdup(name);
262
m_file_mutex = SDL_CreateMutex();
267
CAviFile::~CAviFile (void)
273
SDL_DestroyMutex(m_file_mutex);
278
/* end file avi_file.cpp */