OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef MEDIA_BASE_ANDROID_MEDIA_CODEC_PLAYER_H_ | |
6 #define MEDIA_BASE_ANDROID_MEDIA_CODEC_PLAYER_H_ | |
7 | |
8 #include "base/android/scoped_java_ref.h" | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/memory/weak_ptr.h" | |
11 #include "base/threading/thread.h" | |
12 #include "media/base/android/demuxer_android.h" | |
13 #include "media/base/android/media_player_android.h" | |
14 #include "media/base/media_export.h" | |
15 #include "ui/gl/android/scoped_java_surface.h" | |
16 | |
17 namespace media { | |
18 | |
19 class BrowserCdm; | |
20 | |
21 // Returns the task runner for the media thread | |
22 scoped_refptr<base::SingleThreadTaskRunner> GetMediaTaskRunner(); | |
23 | |
24 | |
25 // This class implements the media player using Android's MediaCodec. | |
xhwang
2015/05/06 17:42:44
nit: Add a comment about the diff b/w this and the
Tima Vaisburd
2015/05/08 07:30:54
Added some words, please take another look
| |
26 class MEDIA_EXPORT MediaCodecPlayer : public MediaPlayerAndroid, | |
27 public DemuxerAndroidClient { | |
28 public: | |
29 // Constructs a player with the given ID and demuxer. |manager| must outlive | |
30 // the lifetime of this object. | |
31 MediaCodecPlayer(int player_id, | |
32 MediaPlayerManager* manager, | |
33 const RequestMediaResourcesCB& request_media_resources_cb, | |
34 scoped_ptr<DemuxerAndroid> demuxer, | |
35 const GURL& frame_url); | |
36 ~MediaCodecPlayer() override; | |
37 | |
38 // MediaPlayerAndroid implementation. | |
39 void DeleteOnCorrectThread() override; | |
40 void SetVideoSurface(gfx::ScopedJavaSurface surface) override; | |
41 void Start() override; | |
42 void Pause(bool is_media_related_action) override; | |
43 void SeekTo(base::TimeDelta timestamp) override; | |
44 void Release() override; | |
45 void SetVolume(double volume) override; | |
46 int GetVideoWidth() override; | |
47 int GetVideoHeight() override; | |
48 base::TimeDelta GetCurrentTime() override; | |
49 base::TimeDelta GetDuration() override; | |
50 bool IsPlaying() override; | |
51 bool CanPause() override; | |
52 bool CanSeekForward() override; | |
53 bool CanSeekBackward() override; | |
54 bool IsPlayerReady() override; | |
55 void SetCdm(BrowserCdm* cdm) override; | |
56 | |
57 // DemuxerAndroidClient implementation. | |
58 void OnDemuxerConfigsAvailable(const DemuxerConfigs& params) override; | |
59 void OnDemuxerDataAvailable(const DemuxerData& params) override; | |
60 void OnDemuxerSeekDone(base::TimeDelta actual_browser_seek_time) override; | |
61 void OnDemuxerDurationChanged(base::TimeDelta duration) override; | |
62 | |
63 // Helper methods | |
64 void Initialize(); | |
65 void DestroySelf(); | |
66 | |
67 private: | |
68 // Object for posting tasks on UI thread. | |
69 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; | |
70 | |
71 scoped_ptr<DemuxerAndroid> demuxer_; | |
72 | |
73 base::WeakPtr<MediaCodecPlayer> weak_this_; | |
74 // NOTE: Weak pointers must be invalidated before all other member variables. | |
75 base::WeakPtrFactory<MediaCodecPlayer> weak_factory_; | |
76 | |
77 DISALLOW_COPY_AND_ASSIGN(MediaCodecPlayer); | |
78 }; | |
79 | |
80 } // namespace media | |
81 | |
82 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_PLAYER_H_ | |
OLD | NEW |