Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: content/browser/media/session/media_session_controllers_manager.cc

Issue 1996043002: Split MediaContentType and AudioFocusType (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed nits Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/media_session_controllers_manager.h" 5 #include "content/browser/media/session/media_session_controllers_manager.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "content/browser/media/session/media_session.h" 8 #include "content/browser/media/session/media_session.h"
9 #include "content/browser/media/session/media_session_controller.h" 9 #include "content/browser/media/session/media_session_controller.h"
10 #include "content/browser/media/session/media_session_observer.h" 10 #include "content/browser/media/session/media_session_observer.h"
(...skipping 27 matching lines...) Expand all
38 return; 38 return;
39 39
40 for (auto it = controllers_map_.begin(); it != controllers_map_.end();) { 40 for (auto it = controllers_map_.begin(); it != controllers_map_.end();) {
41 if (it->first.first == render_frame_host) 41 if (it->first.first == render_frame_host)
42 it = controllers_map_.erase(it); 42 it = controllers_map_.erase(it);
43 else 43 else
44 ++it; 44 ++it;
45 } 45 }
46 } 46 }
47 47
48 bool MediaSessionControllersManager::RequestPlay(const MediaPlayerId& id, 48 bool MediaSessionControllersManager::RequestPlay(
49 bool has_audio, bool is_remote, base::TimeDelta duration) { 49 const MediaPlayerId& id,
50 bool has_audio,
51 bool is_remote,
52 media::MediaContentType media_content_type) {
50 if (!IsDefaultMediaSessionEnabled()) 53 if (!IsDefaultMediaSessionEnabled())
51 return true; 54 return true;
52 55
53 // Since we don't remove session instances on pause, there may be an existing 56 // Since we don't remove session instances on pause, there may be an existing
54 // instance for this playback attempt. 57 // instance for this playback attempt.
55 // 58 //
56 // In this case, try to reinitialize it with the new settings. If they are 59 // In this case, try to reinitialize it with the new settings. If they are
57 // the same, this is a no-op. If the reinitialize fails, destroy the 60 // the same, this is a no-op. If the reinitialize fails, destroy the
58 // controller. A later playback attempt will create a new controller. 61 // controller. A later playback attempt will create a new controller.
59 auto it = controllers_map_.find(id); 62 auto it = controllers_map_.find(id);
60 if (it != controllers_map_.end()) { 63 if (it != controllers_map_.end()) {
61 if (it->second->Initialize(has_audio, is_remote, duration)) 64 if (it->second->Initialize(has_audio, is_remote, media_content_type))
62 return true; 65 return true;
63 controllers_map_.erase(it); 66 controllers_map_.erase(it);
64 return false; 67 return false;
65 } 68 }
66 69
67 std::unique_ptr<MediaSessionController> controller( 70 std::unique_ptr<MediaSessionController> controller(
68 new MediaSessionController(id, media_web_contents_observer_)); 71 new MediaSessionController(id, media_web_contents_observer_));
69 72
70 if (!controller->Initialize(has_audio, is_remote, duration)) 73 if (!controller->Initialize(has_audio, is_remote, media_content_type))
71 return false; 74 return false;
72 75
73 controllers_map_[id] = std::move(controller); 76 controllers_map_[id] = std::move(controller);
74 return true; 77 return true;
75 } 78 }
76 79
77 void MediaSessionControllersManager::OnPause(const MediaPlayerId& id) { 80 void MediaSessionControllersManager::OnPause(const MediaPlayerId& id) {
78 if (!IsDefaultMediaSessionEnabled()) 81 if (!IsDefaultMediaSessionEnabled())
79 return; 82 return;
80 83
81 auto it = controllers_map_.find(id); 84 auto it = controllers_map_.find(id);
82 if (it == controllers_map_.end()) 85 if (it == controllers_map_.end())
83 return; 86 return;
84 87
85 it->second->OnPlaybackPaused(); 88 it->second->OnPlaybackPaused();
86 } 89 }
87 90
88 void MediaSessionControllersManager::OnEnd(const MediaPlayerId& id) { 91 void MediaSessionControllersManager::OnEnd(const MediaPlayerId& id) {
89 if (!IsDefaultMediaSessionEnabled()) 92 if (!IsDefaultMediaSessionEnabled())
90 return; 93 return;
91 controllers_map_.erase(id); 94 controllers_map_.erase(id);
92 } 95 }
93 96
94 } // namespace content 97 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698