Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 "content/browser/media/session/pepper_playback_observer.h" | 5 #include "content/browser/media/session/pepper_playback_observer.h" |
| 6 | 6 |
| 7 #include "base/feature_list.h" | 7 #include "base/feature_list.h" |
| 8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
| 9 #include "content/browser/media/session/media_session.h" | 9 #include "content/browser/media/session/media_session.h" |
| 10 #include "content/browser/media/session/pepper_player_delegate.h" | 10 #include "content/browser/media/session/pepper_player_delegate.h" |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 } | 36 } |
| 37 | 37 |
| 38 void PepperPlaybackObserver::PepperInstanceDeleted(int32_t pp_instance) { | 38 void PepperPlaybackObserver::PepperInstanceDeleted(int32_t pp_instance) { |
| 39 UMA_HISTOGRAM_BOOLEAN("Media.Pepper.PlayedSound", | 39 UMA_HISTOGRAM_BOOLEAN("Media.Pepper.PlayedSound", |
| 40 players_played_sound_map_[pp_instance]); | 40 players_played_sound_map_[pp_instance]); |
| 41 players_played_sound_map_.erase(pp_instance); | 41 players_played_sound_map_.erase(pp_instance); |
| 42 | 42 |
| 43 PepperStopsPlayback(pp_instance); | 43 PepperStopsPlayback(pp_instance); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void PepperPlaybackObserver::PepperStartsPlayback(int32_t pp_instance) { | 46 void PepperPlaybackObserver::PepperStartsPlayback(int32_t pp_instance) { |
|
xhwang
2016/10/18 17:26:59
OOC, what is defined as a "pepper playback"? peppe
Zhiqiang Zhang (Slow)
2016/10/18 18:51:54
It's a pepper plugin instance producing audio.
xhwang
2016/10/18 20:25:08
Could you please add a comment somewhere? IMHO the
Zhiqiang Zhang (Slow)
2016/10/19 10:22:20
Done.
| |
| 47 players_played_sound_map_[pp_instance] = true; | 47 players_played_sound_map_[pp_instance] = true; |
| 48 | 48 |
| 49 if (!base::FeatureList::IsEnabled(media::kFlashJoinsMediaSession)) | 49 if (base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 50 switches::kEnableDefaultMediaSession) != | |
| 51 switches::kEnableDefaultMediaSessionWithFlash) { | |
| 50 return; | 52 return; |
| 53 } | |
| 51 | 54 |
| 52 if (players_map_.count(pp_instance)) | 55 if (players_map_.count(pp_instance)) |
| 53 return; | 56 return; |
| 54 | 57 |
| 55 players_map_[pp_instance].reset(new PepperPlayerDelegate( | 58 players_map_[pp_instance].reset(new PepperPlayerDelegate( |
| 56 contents_, pp_instance)); | 59 contents_, pp_instance)); |
| 57 MediaSession::Get(contents_)->AddPlayer( | 60 MediaSession::Get(contents_)->AddPlayer( |
| 58 players_map_[pp_instance].get(), | 61 players_map_[pp_instance].get(), |
| 59 PepperPlayerDelegate::kPlayerId, | 62 PepperPlayerDelegate::kPlayerId, |
| 60 media::MediaContentType::Pepper); | 63 media::MediaContentType::Pepper); |
| 61 } | 64 } |
| 62 | 65 |
| 63 void PepperPlaybackObserver::PepperStopsPlayback(int32_t pp_instance) { | 66 void PepperPlaybackObserver::PepperStopsPlayback(int32_t pp_instance) { |
| 64 if (!players_map_.count(pp_instance)) | 67 if (!players_map_.count(pp_instance)) |
| 65 return; | 68 return; |
| 66 | 69 |
| 67 MediaSession::Get(contents_)->RemovePlayer( | 70 MediaSession::Get(contents_)->RemovePlayer( |
| 68 players_map_[pp_instance].get(), PepperPlayerDelegate::kPlayerId); | 71 players_map_[pp_instance].get(), PepperPlayerDelegate::kPlayerId); |
| 69 | 72 |
| 70 players_map_.erase(pp_instance); | 73 players_map_.erase(pp_instance); |
| 71 } | 74 } |
| 72 | 75 |
| 73 } // namespace content | 76 } // namespace content |
| OLD | NEW |