home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Geek 6
/
Geek-006.iso
/
linux
/
video
/
xmovie-1.5.3.tar.gz
/
xmovie-1.5.3.tar
/
xmovie-1.5.3
/
xmovie
/
file.C
< prev
next >
Wrap
C/C++ Source or Header
|
2000-11-29
|
4KB
|
217 lines
#include "asset.h"
#include "file.h"
#include "filemov.h"
#include "filempeg.h"
File::File(MainWindow *mwindow)
{
this->mwindow = mwindow;
file = 0;
asset = 0;
cpus = 1;
use_mmx = 1;
}
File::~File()
{
close_file();
}
int File::set_processors(int cpus)
{
this->cpus = cpus;
if(file) file->set_cpus(cpus);
return 0;
}
int File::set_mmx(int use_mmx)
{
this->use_mmx = use_mmx;
if(file) file->set_mmx(use_mmx);
return 0;
}
int File::set_prebuffer(long size)
{
this->prebuffer_size = size;
return 0;
}
int File::open_file(Asset *asset)
{
this->asset = asset;
this->mwindow = mwindow;
// get the format now
FILE *stream;
if(!(stream = fopen(asset->path, "rb")))
{
// file not found
return 1;
}
// ============================== Check formats
// add new formats here
if(mpeg3_check_sig(asset->path))
{
fclose(stream);
file = new FileMPEG(asset, this);
}
else
if(quicktime_check_sig(asset->path))
{
// MOV file
// should be last because quicktime lacks a magic number
fclose(stream);
file = new FileMOV(asset, this);
}
else
{
fclose(stream);
return 2;
}
int result = file->open_file();
total_frames = get_video_length();
total_samples = get_audio_length();
if(result)
{
// failure
delete file;
file = 0;
}
return result;
}
int File::close_file()
{
if(file)
{
file->close_file();
delete file;
}
file = 0;
asset = 0;
return 0;
}
long File::get_audio_length() { return file->get_audio_length(); }
long File::get_video_length() { return file->get_video_length(); }
long File::get_video_position() { return file->get_video_position(); }
long File::get_audio_position() { return file->get_audio_position(); }
int File::get_position(double &percentage, double &seconds)
{
return file->get_position(percentage, seconds);
}
int File::end_of_audio()
{
return file->end_of_audio();
}
int File::end_of_video()
{
return file->end_of_video();
}
int File::set_position(double percentage)
{
return file->set_position(percentage);
}
int File::set_audio_position(long x)
{
file->set_audio_position(x);
return 0;
}
int File::set_video_position(long x)
{
if(x < total_frames)
file->set_video_position(x);
else
file->set_video_position(total_frames - 1);
return 0;
}
int File::set_audio_stream(int stream)
{
if(stream < asset->audio_streams)
return file->set_audio_stream(stream);
return -1;
}
int File::set_video_stream(int stream)
{
if(stream < asset->video_streams)
return file->set_video_stream(stream);
return -1;
}
int File::drop_frames(int frames)
{
return file->drop_frames(frames);
}
int File::frame_back()
{
return file->frame_back();
}
int File::lock_read()
{
read_lock.lock();
return 0;
}
int File::unlock_read()
{
read_lock.unlock();
return 0;
}
int File::read_audio(char *buffer, long len)
{
int result = 0;
if(file) result = file->read_audio(buffer, len);
return result;
}
int File::yuv_copy_possible()
{
if(file) return file->yuv_copy_possible();
return 0;
}
int File::frame_buffer_copy_possible(int color_model)
{
if(file) return file->frame_buffer_copy_possible(color_model);
return 0;
}
int File::read_yuv_buffer(char *y_output, char *u_output, char *v_output, int in_x, int in_y, int in_w, int in_h)
{
if(file) return file->read_yuv_buffer(y_output, u_output, v_output, in_x, in_y, in_w, in_h);
return 1;
}
int File::read_frame_buffer(unsigned char **frame_buffer, int w, int h, int bitmap_color_model)
{
if(file) return file->read_frame_buffer(frame_buffer, w, h, bitmap_color_model);
return 1;
}
int File::read_frame(unsigned char *frame)
{
int result = 1;
if(file) result = file->read_frame(frame);
return result;
}