Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(311)

Unified Diff: content/renderer/media/android/media_source_delegate.h

Issue 23875003: Merge 219225 "Run |demuxer_| related tasks in the media thread i..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1599/src/
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/android/media_source_delegate.h
===================================================================
--- content/renderer/media/android/media_source_delegate.h (revision 220850)
+++ content/renderer/media/android/media_source_delegate.h (working copy)
@@ -9,8 +9,8 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
+#include "base/message_loop/message_loop.h"
#include "base/time/time.h"
-#include "media/base/android/demuxer_stream_player_params.h"
#include "media/base/decryptor.h"
#include "media/base/demuxer.h"
#include "media/base/media_keys.h"
@@ -25,6 +25,7 @@
class DecryptingDemuxerStream;
class DemuxerStream;
class MediaLog;
+struct MediaPlayerHostMsg_DemuxerReady_Params;
struct MediaPlayerHostMsg_ReadFromDemuxerAck_Params;
}
@@ -49,6 +50,7 @@
MediaSourceDelegate(WebMediaPlayerProxyAndroid* proxy,
int player_id,
+ const scoped_refptr<base::MessageLoopProxy>& media_loop,
media::MediaLog* media_log);
// Initialize the MediaSourceDelegate. |media_source| will be owned by
@@ -89,6 +91,13 @@
void Destroy();
private:
+ typedef base::Callback<void(
+ scoped_ptr<media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params> params)>
+ ReadFromDemuxerAckCB;
+ typedef base::Callback<void(
+ scoped_ptr<media::MediaPlayerHostMsg_DemuxerReady_Params> params)>
+ DemuxerReadyCB;
+
// This is private to enforce use of the Destroyer.
virtual ~MediaSourceDelegate();
@@ -138,27 +147,55 @@
const std::string& language);
void NotifyDemuxerReady();
bool CanNotifyDemuxerReady();
+ void SendDemuxerReady(
+ scoped_ptr<media::MediaPlayerHostMsg_DemuxerReady_Params> params);
+ void StopDemuxer();
+ void InitializeDemuxer();
+ void SeekInternal(base::TimeDelta time, unsigned seek_request_id);
+ void OnReadFromDemuxerInternal(media::DemuxerStream::Type type);
// Reads an access unit from the demuxer stream |stream| and stores it in
// the |index|th access unit in |params|.
void ReadFromDemuxerStream(
media::DemuxerStream::Type type,
- media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params* params,
+ scoped_ptr<media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params> params,
size_t index);
void OnBufferReady(
media::DemuxerStream::Type type,
- media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params* params,
+ scoped_ptr<media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params> params,
size_t index,
media::DemuxerStream::Status status,
const scoped_refptr<media::DecoderBuffer>& buffer);
+ void SendReadFromDemuxerAck(
+ scoped_ptr<media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params> params);
+
// Helper function for calculating duration.
int GetDurationMs();
bool HasEncryptedStream();
- base::WeakPtrFactory<MediaSourceDelegate> weak_this_;
+ void SetSeeking(bool seeking);
+ bool IsSeeking() const;
+ // Weak pointer must be dereferenced and invalidated on the same thread.
+ base::WeakPtrFactory<MediaSourceDelegate> main_weak_this_;
+ base::WeakPtrFactory<MediaSourceDelegate> media_weak_this_;
+
+ // Message loop for main renderer thread.
+ const scoped_refptr<base::MessageLoopProxy> main_loop_;
+#if defined(GOOGLE_TV)
+ // Message loop for the media thread.
+ // When there is high load in the render thread, the reading from |demuxer_|
+ // and its read-callback loops run very slowly. To improve the response time
+ // of the readings, we run tasks related to |demuxer_| in the media thread.
+ const scoped_refptr<base::MessageLoopProxy> media_loop_;
+
+ ReadFromDemuxerAckCB send_read_from_demuxer_ack_cb_;
+ base::Closure send_seek_request_ack_cb_;
+ DemuxerReadyCB send_demuxer_ready_cb_;
+#endif
+
WebMediaPlayerProxyAndroid* proxy_;
int player_id_;
@@ -194,10 +231,10 @@
// through GenerateKeyRequest() directly from WebKit.
std::string init_data_type_;
- media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params audio_params_;
- media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params video_params_;
+ // Lock used to serialize access for |seeking_|.
+ mutable base::Lock seeking_lock_;
+ bool seeking_;
- bool seeking_;
base::TimeDelta last_seek_time_;
unsigned last_seek_request_id_;

Powered by Google App Engine
This is Rietveld 408576698