1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Copyright (c) 2013 Intel Corporation. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
6 #ifndef XWALK_TIZEN_BROWSER_BROWSER_MEDIAPLAYER_MANAGER_H_
7 #define XWALK_TIZEN_BROWSER_BROWSER_MEDIAPLAYER_MANAGER_H_
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/scoped_vector.h"
11 #include "content/public/browser/web_contents_observer.h"
13 #include "xwalk/tizen/browser/audio_session_manager.h"
17 // This class manages all AudioSessionManager objects in the browser
18 // process. It receives control operations from the render process, and
19 // forwards them to corresponding AudioSessionManager object. Callbacks
20 // from AudioSessionManager objects are converted to IPCs and then sent
21 // to the render process.
22 class CONTENT_EXPORT BrowserMediaPlayerManager
23 : public content::WebContentsObserver {
25 virtual ~BrowserMediaPlayerManager();
27 // Returns a new instance.
28 static BrowserMediaPlayerManager* Create(
29 content::RenderViewHost* render_view_host);
31 // WebContentsObserver overrides.
32 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
33 virtual AudioSessionManager* GetAudioSessionManager(
34 MediaPlayerID player_id) OVERRIDE;
36 ASM_cb_result_t AudioSessionEventPause(
37 ASM_event_sources_t eventSource, MediaPlayerID player_id);
38 ASM_cb_result_t AudioSessionEventPlay(
39 ASM_event_sources_t eventSource, MediaPlayerID player_id);
42 explicit BrowserMediaPlayerManager(content::RenderViewHost* render_view_host);
45 virtual void OnInitialize(MediaPlayerID player_id,
46 int process_id, const GURL& url);
47 virtual void OnDestroyAllMediaPlayers();
48 virtual void OnDestroyPlayer(MediaPlayerID player_id);
49 virtual void OnPause(MediaPlayerID player_id);
50 virtual void OnStart(MediaPlayerID player_id);
52 // Adds a audio session manager for the given player to the list.
53 void AddAudioSessionManager(AudioSessionManager* session_manager);
55 // Removes the audio session manager of given |player_id|.
56 void RemoveAudioSessionManager(MediaPlayerID player_id);
58 ScopedVector<AudioSessionManager> audio_session_managers_;
60 DISALLOW_COPY_AND_ASSIGN(BrowserMediaPlayerManager);
65 #endif // XWALK_TIZEN_BROWSER_BROWSER_MEDIAPLAYER_MANAGER_H_