summaryrefslogtreecommitdiffstats
path: root/media/base/android/media_source_player.h
diff options
context:
space:
mode:
authoracolwell@chromium.org <acolwell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-23 02:16:10 +0000
committeracolwell@chromium.org <acolwell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-23 02:16:10 +0000
commitb506845ad558d82326d37336a4801ae8dc25f2da (patch)
tree64f5306d4d200fd9dd2d0b4180c7cc42c856d835 /media/base/android/media_source_player.h
parentd791ad1ba1cd9246b83ecf3a8622006706fb9605 (diff)
downloadchromium_src-b506845ad558d82326d37336a4801ae8dc25f2da.zip
chromium_src-b506845ad558d82326d37336a4801ae8dc25f2da.tar.gz
chromium_src-b506845ad558d82326d37336a4801ae8dc25f2da.tar.bz2
Move MediaDecoderJob functionality out into separate files and refactor.
Minor code changes were also made to move audio or video specific functionality out of the base class and into the derived classes. No functionality changes were introduced. Code is just being moved around. TEST=All existing tests still pass. Review URL: https://chromiumcodereview.appspot.com/23003019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@219188 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base/android/media_source_player.h')
-rw-r--r--media/base/android/media_source_player.h105
1 files changed, 4 insertions, 101 deletions
diff --git a/media/base/android/media_source_player.h b/media/base/android/media_source_player.h
index 05fd224..c475762 100644
--- a/media/base/android/media_source_player.h
+++ b/media/base/android/media_source_player.h
@@ -18,115 +18,18 @@
#include "base/threading/thread.h"
#include "base/time/default_tick_clock.h"
#include "base/time/time.h"
-#include "media/base/android/demuxer_stream_player_params.h"
#include "media/base/android/media_codec_bridge.h"
+#include "media/base/android/media_decoder_job.h"
#include "media/base/android/media_player_android.h"
#include "media/base/clock.h"
#include "media/base/media_export.h"
-namespace base {
-class MessageLoopProxy;
-}
-
namespace media {
class AudioDecoderJob;
class AudioTimestampHelper;
class VideoDecoderJob;
-// Class for managing all the decoding tasks. Each decoding task will be posted
-// onto the same thread. The thread will be stopped once Stop() is called.
-class MediaDecoderJob {
- public:
- enum DecodeStatus {
- DECODE_SUCCEEDED,
- DECODE_TRY_ENQUEUE_INPUT_AGAIN_LATER,
- DECODE_TRY_DEQUEUE_OUTPUT_AGAIN_LATER,
- DECODE_FORMAT_CHANGED,
- DECODE_INPUT_END_OF_STREAM,
- DECODE_OUTPUT_END_OF_STREAM,
- DECODE_FAILED,
- };
-
- virtual ~MediaDecoderJob();
-
- // Callback when a decoder job finishes its work. Args: whether decode
- // finished successfully, presentation time, audio output bytes.
- typedef base::Callback<void(DecodeStatus, const base::TimeDelta&,
- size_t)> DecoderCallback;
-
- // Called by MediaSourcePlayer to decode some data.
- void Decode(const AccessUnit& unit,
- const base::TimeTicks& start_time_ticks,
- const base::TimeDelta& start_presentation_timestamp,
- const MediaDecoderJob::DecoderCallback& callback);
-
- // Flush the decoder.
- void Flush();
-
- // Causes this instance to be deleted on the thread it is bound to.
- void Release();
-
- // Called on the UI thread to indicate that one decode cycle has completed.
- void OnDecodeCompleted();
-
- bool is_decoding() const { return is_decoding_; }
-
- protected:
- MediaDecoderJob(const scoped_refptr<base::MessageLoopProxy>& decoder_loop,
- MediaCodecBridge* media_codec_bridge,
- bool is_audio);
-
- // Release the output buffer and render it.
- void ReleaseOutputBuffer(
- int outputBufferIndex, size_t size,
- const base::TimeDelta& presentation_timestamp,
- const MediaDecoderJob::DecoderCallback& callback, DecodeStatus status);
-
- DecodeStatus QueueInputBuffer(const AccessUnit& unit);
-
- // Helper function to decoder data on |thread_|. |unit| contains all the data
- // to be decoded. |start_time_ticks| and |start_presentation_timestamp|
- // represent the system time and the presentation timestamp when the first
- // frame is rendered. We use these information to estimate when the current
- // frame should be rendered. If |needs_flush| is true, codec needs to be
- // flushed at the beginning of this call.
- void DecodeInternal(const AccessUnit& unit,
- const base::TimeTicks& start_time_ticks,
- const base::TimeDelta& start_presentation_timestamp,
- bool needs_flush,
- const MediaDecoderJob::DecoderCallback& callback);
-
- // The UI message loop where callbacks should be dispatched.
- scoped_refptr<base::MessageLoopProxy> ui_loop_;
-
- // The message loop that decoder job runs on.
- scoped_refptr<base::MessageLoopProxy> decoder_loop_;
-
- // The media codec bridge used for decoding.
- scoped_ptr<MediaCodecBridge> media_codec_bridge_;
-
- // Whether the decoder needs to be flushed.
- bool needs_flush_;
-
- // Whether this is an audio decoder.
- bool is_audio_;
-
- // Whether input EOS is encountered.
- bool input_eos_encountered_;
-
- // Weak pointer passed to media decoder jobs for callbacks. It is bounded to
- // the decoder thread.
- base::WeakPtrFactory<MediaDecoderJob> weak_this_;
-
- // Whether the decoder is actively decoding data.
- bool is_decoding_;
-};
-
-struct DecoderJobDeleter {
- inline void operator()(MediaDecoderJob* ptr) const { ptr->Release(); }
-};
-
// This class handles media source extensions on Android. It uses Android
// MediaCodec to decode audio and video streams in two separate threads.
// IPC is being used to send data from the render process to this object.
@@ -271,9 +174,9 @@ class MEDIA_EXPORT MediaSourcePlayer : public MediaPlayerAndroid {
// The surface object currently owned by the player.
gfx::ScopedJavaSurface surface_;
- // Decoder jobs
- scoped_ptr<AudioDecoderJob, DecoderJobDeleter> audio_decoder_job_;
- scoped_ptr<VideoDecoderJob, DecoderJobDeleter> video_decoder_job_;
+ // Decoder jobs.
+ scoped_ptr<AudioDecoderJob, MediaDecoderJob::Deleter> audio_decoder_job_;
+ scoped_ptr<VideoDecoderJob, MediaDecoderJob::Deleter> video_decoder_job_;
bool reconfig_audio_decoder_;
bool reconfig_video_decoder_;