Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 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 #include "content/browser/media/session/pepper_player_delegate.h" | |
| 6 | |
| 7 #include "content/browser/frame_host/render_frame_host_impl.h" | |
| 8 #include "content/browser/media/session/pepper_playback_observer.h" | |
| 9 #include "content/browser/web_contents/web_contents_impl.h" | |
| 10 #include "content/common/frame_messages.h" | |
| 11 | |
| 12 namespace content { | |
| 13 | |
| 14 namespace { | |
| 15 const double kDuckVolume = 0.2f; | |
| 16 const int kPlayerId = 0; | |
|
dcheng
2016/07/01 05:57:59
Note: this is fine, but my comment was directed mo
Zhiqiang Zhang (Slow)
2016/07/01 11:01:07
OK, now I moved all the Ids in one place (pepper_p
| |
| 17 } // anonymous namespace | |
| 18 | |
| 19 PepperPlayerDelegate::PepperPlayerDelegate( | |
| 20 WebContentsImpl* contents, int32_t pp_instance) | |
| 21 : contents_(contents), | |
| 22 pp_instance_(pp_instance) {} | |
| 23 | |
| 24 PepperPlayerDelegate::~PepperPlayerDelegate() = default; | |
| 25 | |
| 26 void PepperPlayerDelegate::OnSuspend(int player_id) { | |
| 27 // Pepper player cannot be really suspended. Duck the volume instead. | |
| 28 DCHECK_EQ(player_id, kPlayerId); | |
| 29 SetVolume(player_id, kDuckVolume); | |
| 30 } | |
| 31 | |
| 32 void PepperPlayerDelegate::OnResume(int player_id) { | |
| 33 DCHECK_EQ(player_id, kPlayerId); | |
| 34 SetVolume(player_id, 1.0f); | |
| 35 } | |
| 36 | |
| 37 void PepperPlayerDelegate::OnSetVolumeMultiplier(int player_id, | |
| 38 double volume_multiplier) { | |
| 39 DCHECK_EQ(player_id, kPlayerId); | |
| 40 SetVolume(player_id, volume_multiplier); | |
| 41 } | |
| 42 | |
| 43 void PepperPlayerDelegate::SetVolume(int player_id, double volume) { | |
| 44 contents_->Send(new FrameMsg_SetPepperVolume( | |
| 45 contents_->GetMainFrame()->routing_id(), pp_instance_, volume)); | |
| 46 } | |
| 47 | |
| 48 } // namespace content | |
| OLD | NEW |