OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/base/android/media_player_android.h" | 5 #include "media/base/android/media_player_android.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/android/context_utils.h" | 9 #include "base/android/context_utils.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
12 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
13 #include "media/base/android/media_drm_bridge.h" | 13 #include "media/base/android/media_drm_bridge.h" |
14 #include "media/base/android/media_player_manager.h" | 14 #include "media/base/android/media_player_manager.h" |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 const double kDefaultVolume = 1.0; | 18 const double kDefaultVolume = 1.0; |
19 | 19 |
20 } // namespace | 20 } // namespace |
21 | 21 |
22 namespace media { | 22 namespace media { |
23 | 23 |
24 const double MediaPlayerAndroid::kDefaultVolumeMultiplier = 1.0; | 24 const double MediaPlayerAndroid::kDefaultVolumeMultiplier = 1.0; |
25 | 25 |
26 MediaPlayerAndroid::MediaPlayerAndroid( | 26 MediaPlayerAndroid::MediaPlayerAndroid( |
27 int player_id, | 27 int player_id, |
28 MediaPlayerManager* manager, | 28 MediaPlayerManager* manager, |
29 const OnDecoderResourcesReleasedCB& on_decoder_resources_released_cb, | 29 const OnDecoderResourcesReleasedCB& on_decoder_resources_released_cb, |
30 const GURL& frame_url) | 30 const GURL& frame_url, |
| 31 int media_session_id) |
31 : on_decoder_resources_released_cb_(on_decoder_resources_released_cb), | 32 : on_decoder_resources_released_cb_(on_decoder_resources_released_cb), |
32 player_id_(player_id), | 33 player_id_(player_id), |
33 volume_(kDefaultVolume), | 34 volume_(kDefaultVolume), |
34 volume_multiplier_(kDefaultVolumeMultiplier), | 35 volume_multiplier_(kDefaultVolumeMultiplier), |
35 manager_(manager), | 36 manager_(manager), |
36 frame_url_(frame_url), | 37 frame_url_(frame_url), |
37 weak_factory_(this) { | 38 weak_factory_(this), |
| 39 media_session_id_(media_session_id) { |
38 listener_.reset(new MediaPlayerListener(base::ThreadTaskRunnerHandle::Get(), | 40 listener_.reset(new MediaPlayerListener(base::ThreadTaskRunnerHandle::Get(), |
39 weak_factory_.GetWeakPtr())); | 41 weak_factory_.GetWeakPtr())); |
40 } | 42 } |
41 | 43 |
42 MediaPlayerAndroid::~MediaPlayerAndroid() {} | 44 MediaPlayerAndroid::~MediaPlayerAndroid() {} |
43 | 45 |
44 void MediaPlayerAndroid::SetVolume(double volume) { | 46 void MediaPlayerAndroid::SetVolume(double volume) { |
45 volume_ = std::max(0.0, std::min(volume, 1.0)); | 47 volume_ = std::max(0.0, std::min(volume, 1.0)); |
46 UpdateEffectiveVolume(); | 48 UpdateEffectiveVolume(); |
47 } | 49 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 void MediaPlayerAndroid::DestroyListenerOnUIThread() { | 120 void MediaPlayerAndroid::DestroyListenerOnUIThread() { |
119 weak_factory_.InvalidateWeakPtrs(); | 121 weak_factory_.InvalidateWeakPtrs(); |
120 listener_.reset(); | 122 listener_.reset(); |
121 } | 123 } |
122 | 124 |
123 base::WeakPtr<MediaPlayerAndroid> MediaPlayerAndroid::WeakPtrForUIThread() { | 125 base::WeakPtr<MediaPlayerAndroid> MediaPlayerAndroid::WeakPtrForUIThread() { |
124 return weak_factory_.GetWeakPtr(); | 126 return weak_factory_.GetWeakPtr(); |
125 } | 127 } |
126 | 128 |
127 } // namespace media | 129 } // namespace media |
OLD | NEW |