Index: media/base/android/media_source_player_impl.h |
diff --git a/media/base/android/media_source_player_impl.h b/media/base/android/media_source_player_impl.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..299f09e94849d444d4ea0723340e409fa920b083 |
--- /dev/null |
+++ b/media/base/android/media_source_player_impl.h |
@@ -0,0 +1,73 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef MEDIA_BASE_ANDROID_MEDIA_SOURCE_PLAYER_IMPL_H_ |
+#define MEDIA_BASE_ANDROID_MEDIA_SOURCE_PLAYER_IMPL_H_ |
+ |
+#include "base/android/scoped_java_ref.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "base/memory/weak_ptr.h" |
+#include "base/threading/thread.h" |
+#include "media/base/android/demuxer_android.h" |
+#include "media/base/media_export.h" |
+#include "ui/gl/android/scoped_java_surface.h" |
+ |
+namespace media { |
+ |
+class BrowserCdm; |
+ |
+// This class implements the media source extensions on Android. |
+ |
+// The separation between MediaSourcePlayer and MediaSourcePlayerImpl |
+// is introduced for the postponed destruction of MediaSourcePlayerImpl |
+// that happens on the Media thread. |
+ |
+class MEDIA_EXPORT MediaSourcePlayerImpl : public DemuxerAndroidClient { |
+ public: |
+ // Constructs a player with the given ID and demuxer. |manager| must outlive |
+ // the lifetime of this object. |
+ MediaSourcePlayerImpl(scoped_ptr<DemuxerAndroid> demuxer); |
+ ~MediaSourcePlayerImpl(); |
+ |
+ // Forwarded from MediaSourceImpl |
+ void SetVideoSurface(gfx::ScopedJavaSurface surface); |
+ void Start(); |
+ void Pause(); |
+ void SeekTo(base::TimeDelta timestamp); |
+ void Release(); |
+ void SetVolume(double volume); |
+ int GetVideoWidth(); |
+ int GetVideoHeight(); |
+ base::TimeDelta GetCurrentTime(); |
+ base::TimeDelta GetDuration(); |
+ bool IsPlaying(); |
+ bool CanPause(); |
+ bool CanSeekForward(); |
+ bool CanSeekBackward(); |
+ bool IsPlayerReady(); |
+ void SetCdm(BrowserCdm* cdm); |
+ |
+ // DemuxerAndroidClient implementation. |
+ void OnDemuxerConfigsAvailable(const DemuxerConfigs& params) override; |
+ void OnDemuxerDataAvailable(const DemuxerData& params) override; |
+ void OnDemuxerSeekDone(base::TimeDelta actual_browser_seek_time) override; |
+ void OnDemuxerDurationChanged(base::TimeDelta duration) override; |
+ |
+ // Helper methods |
+ void Initialize(); |
+ void DestroySelf(); |
+ |
+ private: |
+ scoped_ptr<DemuxerAndroid> demuxer_; |
+ |
+ base::WeakPtr<MediaSourcePlayerImpl> weak_this_; |
+ // NOTE: Weak pointers must be invalidated before all other member variables. |
+ base::WeakPtrFactory<MediaSourcePlayerImpl> weak_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(MediaSourcePlayerImpl); |
+}; |
+ |
+} // namespace media |
+ |
+#endif // MEDIA_BASE_ANDROID_MEDIA_SOURCE_PLAYER_IMPL_H_ |