DVDIO Class Reference

* More...

#include <DVDIO.hpp>

Inheritance diagram for DVDIO:

IO VThread List of all members.

Public Member Functions

 DVDIO (ESInfo *es_info, const char *file_name)
FramegetFrame ()
 returns a frame if one complete frame is available, otherwise null is returned.
bool open ()
 opens the IO connection.
void setESInfo (ESInfo *es)
ESInfogetESInfo ()
int writeFrame (Frame *, ESInfo *out_es=NULL)
 returns the number of packets sent.
bool close (bool immediate=false)
 closes the IO class.
bool destroy ()
 delete the vob file
int getBufferFillLevel () const
 returns a value from 0..100 indicating buffer usage
const char * getURL () const
 returns a pointer to the local file name or an URL

Protected Attributes

ESInfoesinfo
char * filename
AVFormatContext * av_format_context
AVInputFormat * av_input_format
AVFormatParameters * av_format_parameters
int streamID
u64 DTS

Detailed Description

*

Definition at line 59 of file DVDIO.hpp.


Member Function Documentation

bool DVDIO::close bool  immediate = false  )  [inline, virtual]
 

closes the IO class.

Parameters:
immediate specifies, if (optional) buffered data should be read/sent to the client (==false), or immediately dumped (==true)

Implements IO.

Definition at line 87 of file DVDIO.hpp.

Referenced by getFrame().

00087 { state=CLOSED; /*assert("IMPLEMENT ME");*/ return true;};

Frame * DVDIO::getFrame  )  [virtual]
 

returns a frame if one complete frame is available, otherwise null is returned.

This function is typically blocking. Don't use a NULL return value to conclude STREAMEOF, always check with getState()!

Implements IO.

Definition at line 79 of file DVDIO.cpp.

References close(), ESInfo::getStreamId(), Frame::getType(), ESInfo::isVisualStream(), Frame::setAU(), and Frame::setMediaTimeScale().

00079 { 00080 if(state!=OPEN) 00081 return NULL; 00082 00083 printf("============================================================\n"); 00084 printf("DVDIO::getFrame: \n"); 00085 if (( (this->currentFrameNumber > this->endFrameNumber) && (endFrameNumber!=0) )) { 00086 close(true); 00087 state=STREAMEOF; 00088 return NULL; 00089 } 00090 00091 Frame *frame = NULL; 00092 AU *access_unit = new AU(); 00093 AVPacket avpacket_1, *avpacket = &avpacket_1; 00094 streamID = esinfo->getStreamId(); 00095 00096 printf("Getting new Frame from streamID: %i\n",streamID); 00097 printf("IDs:"); 00098 // to get correct stream, brute @ moment, maybe improove! 00099 do { 00100 if(av_read_frame(av_format_context, avpacket)){ 00101 printf("Error reading avpacket!\n"); 00102 return NULL; 00103 } 00104 printf(" %i ",av_format_context->streams[avpacket->stream_index]->id ); 00105 00106 if(av_format_context->streams[avpacket->stream_index]->id != streamID) { 00107 //printf("DVDIO::getFrame: Wrong ID -> dropping packet\n"); 00108 av_free_packet(avpacket); 00109 } 00110 00111 } while (av_format_context->streams[avpacket->stream_index]->id != streamID); 00112 printf("\nCorrect ID found! -> "); 00113 00114 // access_unit stuff copied from ffmp4io 00115 access_unit->size = avpacket->size; 00116 00117 access_unit->cts = DTS; 00118 access_unit->dts = DTS; 00119 DTS+=((VideoESInfo*)esinfo)->getVOPTimeIncrement(); 00120 access_unit->payload = new u8[access_unit->size]; 00121 memcpy(access_unit->payload, avpacket->data, access_unit->size); 00122 00123 // packet no longer needed! 00124 av_free_packet(avpacket); 00125 00126 // create frame copied from ffmp4io 00127 if(esinfo->isVisualStream()) 00128 frame = new CompressedVideoFrame(Frame::NN_VOP, ((VideoESInfo*)esinfo)->getWidth(), ((VideoESInfo*)esinfo)->getHeight()); 00129 else if(esinfo->isAudioStream()) 00130 frame = new CompressedAudioFrame(Frame::NN_VOP); 00131 else //hack for any other stream type maybe subpic in the future! 00132 frame = new CompressedVideoFrame(Frame::NN_VOP,0,0); 00133 00134 if (!frame->setAU(access_unit)) { //automatically detects frame type 00135 printf("Failed to set access unit at frame?\n"); 00136 } 00137 frame->setMediaTimeScale(esinfo->getMediaTimeScale()); 00138 00139 // frame type output 00140 Frame::FrameType ft = frame->getType(); 00141 printf("FrameType = %s\n\n", Frame::VOPTypeToChar(ft)); 00142 currentFrameNumber++; 00143 return frame; 00144 }

bool DVDIO::open  )  [virtual]
 

opens the IO connection.

State is set to OPENING. Depending on the underlying QIODevice, a network connection or a file connection is established. When the connection is ready for use, State is OPEN

Implements IO.

Definition at line 63 of file DVDIO.cpp.

00063 { 00064 if(state!=OPEN) { 00065 int error; 00066 printf("DVDIO::open:\n"); 00067 printf("Opening VOB file \n"); 00068 av_register_all(); 00069 error = av_open_input_file(&av_format_context, filename, av_input_format, 0, av_format_parameters); 00070 state = OPEN; 00071 return (error==0); 00072 currentFrameNumber=0; 00073 } 00074 return true; 00075 00076 };

int DVDIO::writeFrame Frame ,
ESInfo out_es = NULL
[inline, virtual]
 

returns the number of packets sent.

Returns 0 on error

Implements IO.

Definition at line 84 of file DVDIO.hpp.

00084 { assert(false); return 1;};


The documentation for this class was generated from the following files: