Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/huceke/omxplayer
Browse files Browse the repository at this point in the history
Conflicts:
	OMXReader.cpp
	OMXReader.h
  • Loading branch information
torarin committed Jun 11, 2012
2 parents ccf7227 + 65c1192 commit b0980ac
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 11 deletions.
4 changes: 4 additions & 0 deletions DllAvUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class DllAvUtilInterface
virtual int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)=0;
virtual int av_samples_get_buffer_size (int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align) = 0;
virtual int64_t av_get_default_channel_layout(int nb_channels)=0;
virtual void av_log_set_level(int level) = 0;
};

#if defined (USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN)
Expand Down Expand Up @@ -143,6 +144,7 @@ class DllAvUtilBase : public DllDynamic, DllAvUtilInterface
virtual int av_samples_get_buffer_size (int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
{ return ::av_samples_get_buffer_size(linesize, nb_channels, nb_samples, sample_fmt, align); }
virtual int64_t av_get_default_channel_layout(int nb_channels) { return ::av_get_default_channel_layout(nb_channels); }
virtual void av_log_set_level(int level) { ::av_log_set_level(level); };

// DLL faking.
virtual bool ResolveExports() { return true; }
Expand Down Expand Up @@ -184,6 +186,7 @@ class DllAvUtilBase : public DllDynamic, DllAvUtilInterface
DEFINE_METHOD4(int, av_dict_set, (AVDictionary **p1, const char *p2, const char *p3, int p4));
DEFINE_METHOD5(int, av_samples_get_buffer_size, (int *p1, int p2, int p3, enum AVSampleFormat p4, int p5))
DEFINE_METHOD1(int64_t, av_get_default_channel_layout, (int p1))
DEFINE_METHOD1(void, av_log_set_level, (int p1))

public:
BEGIN_METHOD_RESOLVE()
Expand All @@ -210,6 +213,7 @@ class DllAvUtilBase : public DllDynamic, DllAvUtilInterface
RESOLVE_METHOD(av_dict_set)
RESOLVE_METHOD(av_samples_get_buffer_size)
RESOLVE_METHOD(av_get_default_channel_layout)
RESOLVE_METHOD(av_log_set_level)
END_METHOD_RESOLVE()
};

Expand Down
12 changes: 12 additions & 0 deletions OMXPlayerAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,18 @@ void OMXPlayerAudio::SetCurrentVolume(long nVolume)
if(m_decoder) m_decoder->SetCurrentVolume(nVolume);
}

long OMXPlayerAudio::GetCurrentVolume()
{
if(m_decoder)
{
return m_decoder->GetCurrentVolume();
}
else
{
return 0;
}
}

void OMXPlayerAudio::SetSpeed(int speed)
{
m_speed = speed;
Expand Down
1 change: 1 addition & 0 deletions OMXPlayerAudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class OMXPlayerAudio : public CThread
void UnRegisterAudioCallback();
void DoAudioWork();
void SetCurrentVolume(long nVolume);
long GetCurrentVolume();
void SetSpeed(int iSpeed);
bool Error() { return !m_player_error; };
};
Expand Down
25 changes: 18 additions & 7 deletions OMXReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ bool OMXReader::Open(std::string filename, bool dump_format)

m_dllAvFormat.av_register_all();
m_dllAvFormat.avformat_network_init();
m_dllAvUtil.av_log_set_level(AV_LOG_QUIET);

int result = -1;
AVInputFormat *iformat = NULL;
Expand Down Expand Up @@ -389,9 +390,13 @@ bool OMXReader::SeekTime(int64_t seek_ms, int seek_flags, double *startpts)
UpdateCurrentPTS();

if(m_iCurrentPts == DVD_NOPTS_VALUE)
{
CLog::Log(LOGDEBUG, "OMXReader::SeekTime - unknown position after seek");
}
else
{
CLog::Log(LOGDEBUG, "OMXReader::SeekTime - seek ended up on time %d",(int)(m_iCurrentPts / DVD_TIME_BASE * 1000));
}

if(startpts)
*startpts = DVD_MSEC_TO_TIME(seek_ms);
Expand Down Expand Up @@ -569,23 +574,21 @@ bool OMXReader::GetStreams()
{
if(m_program == UINT_MAX && m_pFormatContext->programs[i]->nb_stream_indexes > 0)
m_program = i;

if(i != m_program)
m_pFormatContext->programs[i]->discard = AVDISCARD_ALL;
}
if(m_program != UINT_MAX)
{
// TODO: build stream array
// add streams from selected program
for (unsigned int i = 0; i < m_pFormatContext->programs[m_program]->nb_stream_indexes; i++)
AddStream(m_pFormatContext->programs[m_program]->stream_index[i]);
}
}
}

// if there were no programs or they were all empty, add all streams
// if there were no programs or they were all empty, add all streams
if (m_program == UINT_MAX)
{
// TODO: build stream array
for (unsigned int i = 0; i < m_pFormatContext->nb_streams; i++)
AddStream(i);
}
Expand Down Expand Up @@ -714,15 +717,15 @@ bool OMXReader::SetActiveStreamInternal(OMXStreamType type, unsigned int index)
switch(type)
{
case OMXSTREAM_AUDIO:
if(index > (m_audio_count - 1))
if((int)index > (m_audio_count - 1))
index = (m_audio_count - 1);
break;
case OMXSTREAM_VIDEO:
if(index > (m_video_count - 1))
if((int)index > (m_video_count - 1))
index = (m_video_count - 1);
break;
case OMXSTREAM_SUBTITLE:
if(index > (m_subtitle_count - 1))
if((int)index > (m_subtitle_count - 1))
index = (m_subtitle_count - 1);
break;
default:
Expand Down Expand Up @@ -1317,3 +1320,11 @@ int OMXReader::GetSourceBitrate()
return ret;
}
#endif

bool OMXReader::CanSeek()
{
if(m_ioContext)
return m_ioContext->seekable;

return false;
}
1 change: 1 addition & 0 deletions OMXReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ class OMXReader
std::string GetStreamLanguage(OMXStreamType type, unsigned int index);
std::string GetStreamName(OMXStreamType type, unsigned int index);
std::string GetStreamType(OMXStreamType type, unsigned int index);
bool CanSeek();
#ifndef STANDALONE
int GetSourceBitrate();
#endif
Expand Down
16 changes: 12 additions & 4 deletions omxplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,16 +532,16 @@ int main(int argc, char *argv[])
goto do_exit;
break;
case 0x5b44: // key left
m_incr = -30.0;
if(m_omx_reader.CanSeek()) m_incr = -30.0;
break;
case 0x5b43: // key right
m_incr = 30.0;
if(m_omx_reader.CanSeek()) m_incr = 30.0;
break;
case 0x5b41: // key up
m_incr = 600.0;
if(m_omx_reader.CanSeek()) m_incr = 600.0;
break;
case 0x5b42: // key down
m_incr = -600.0;
if(m_omx_reader.CanSeek()) m_incr = -600.0;
break;
case ' ':
case 'p':
Expand All @@ -557,6 +557,14 @@ int main(int argc, char *argv[])
m_av_clock->OMXResume();
}
break;
case '-':
m_player_audio.SetCurrentVolume(m_player_audio.GetCurrentVolume() - 50);
printf("Current Volume: %.2fdB\n", m_player_audio.GetCurrentVolume() / 100.0f);
break;
case '+':
m_player_audio.SetCurrentVolume(m_player_audio.GetCurrentVolume() + 50);
printf("Current Volume: %.2fdB\n", m_player_audio.GetCurrentVolume() / 100.0f);
break;
default:
break;
}
Expand Down

0 comments on commit b0980ac

Please sign in to comment.