Skip to content

Commit

Permalink
Decoder: Use the RingBuffer to decide streaming parameters.
Browse files Browse the repository at this point in the history
The http/streaming ringbuffer may need an ajustment.
  • Loading branch information
Mark Kendall committed Mar 14, 2011
1 parent 81c861d commit 0616838
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
20 changes: 6 additions & 14 deletions mythtv/libs/libmythtv/avformatdecoder.cpp
Expand Up @@ -794,26 +794,18 @@ bool AvFormatDecoder::CanHandle(char testbuf[kDecoderProbeBufferSize],

void AvFormatDecoder::InitByteContext(void)
{
int streamed = 0;
int buffer_size = 32768;

if (ringBuffer->IsDVD())
{
streamed = 1;
buffer_size = 2048;
}
else if (ringBuffer->LiveMode())
streamed = 1;
int buf_size = ringBuffer->BestBufferSize();
int streamed = ringBuffer->IsStreamed();
VERBOSE(VB_PLAYBACK, LOC + QString("Buffer size: %1, streamed %2")
.arg(buf_size).arg(streamed));

readcontext.prot = &AVF_RingBuffer_Protocol;
readcontext.flags = 0;
readcontext.is_streamed = streamed;
readcontext.max_packet_size = 0;
readcontext.priv_data = avfRingBuffer;

unsigned char* buffer = (unsigned char *)av_malloc(buffer_size);

ic->pb = av_alloc_put_byte(buffer, buffer_size, 0,
unsigned char* buffer = (unsigned char *)av_malloc(buf_size);
ic->pb = av_alloc_put_byte(buffer, buf_size, 0,
&readcontext,
AVF_Read_Packet,
AVF_Write_Packet,
Expand Down
2 changes: 2 additions & 0 deletions mythtv/libs/libmythtv/bdringbuffer.h
Expand Up @@ -51,6 +51,8 @@ class MTV_PUBLIC BDRingBuffer : public RingBuffer
BDRingBuffer(const QString &lfilename);
virtual ~BDRingBuffer();

virtual bool IsStreamed(void) { return true; }

void ProgressUpdate(void);

// Player interaction
Expand Down
2 changes: 2 additions & 0 deletions mythtv/libs/libmythtv/dvdringbuffer.h
Expand Up @@ -47,6 +47,8 @@ class MTV_PUBLIC DVDRingBuffer : public RingBuffer
void GetPartAndTitle(int &_part, int &_title) const
{ _part = m_part; _title = m_title; }
uint GetTotalTimeOfTitle(void);
virtual bool IsStreamed(void) { return true; }
virtual int BestBufferSize(void) { return 2048; }

uint GetCellStart(void);
bool PGCLengthChanged(void);
Expand Down
2 changes: 2 additions & 0 deletions mythtv/libs/libmythtv/ringbuffer.h
Expand Up @@ -62,6 +62,8 @@ class MTV_PUBLIC RingBuffer : protected QThread
bool IsNearEnd(double fps, uint vvf) const;
/// \brief Returns true if open for either reading or writing.
virtual bool IsOpen(void) const = 0;
virtual bool IsStreamed(void) { return LiveMode(); }
virtual int BestBufferSize(void) { return 32768; }

// DVD and bluray methods
bool IsDisc(void) const { return IsDVD() || IsBD(); }
Expand Down
1 change: 1 addition & 0 deletions mythtv/libs/libmythtv/streamingringbuffer.h
Expand Up @@ -19,6 +19,7 @@ class StreamingRingBuffer : public RingBuffer
uint retry_ms = kDefaultOpenTimeout);
virtual long long Seek(long long pos, int whence, bool has_lock);
virtual long long GetRealFileSize(void);
virtual bool IsStreamed(void) { return true; }

protected:
virtual int safe_read(void *data, uint sz);
Expand Down

0 comments on commit 0616838

Please sign in to comment.