blob: b01a3bf916a02555186884fdc6ffccae68edef27 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_ANDROID_MEDIA_PLAYERS_OBSERVER_H_
#define CONTENT_BROWSER_ANDROID_MEDIA_PLAYERS_OBSERVER_H_
#include <map>
#include "base/macros.h"
#include "content/browser/media/audio_state_provider.h"
namespace content {
class RenderFrameHost;
// On Android the MediaPlayerAndroid objects report
// the audible state to us.
class MediaPlayersObserver : public AudioStateProvider {
public:
explicit MediaPlayersObserver(WebContents* web_contents);
~MediaPlayersObserver() override;
bool IsAudioStateAvailable() const override;
// This audio state provider does not have a monitor,
// the method returns nullptr.
AudioStreamMonitor* audio_stream_monitor() override;
// These methods constitute the observer pattern, should
// be called when corresponding event happens. They will notify
// WebContents whenever its audible state as a whole changes.
void OnAudibleStateChanged(RenderFrameHost* rfh, int player_id,
bool is_audible);
void RemovePlayer(RenderFrameHost* rfh, int player_id);
void RenderFrameDeleted(RenderFrameHost* rfh);
private:
void UpdateStatusAndNotify();
// Audible status per player ID and frame
typedef std::pair<RenderFrameHost*, int> Key;
typedef std::map<Key, bool> StatusMap;
StatusMap audio_status_map_;
DISALLOW_COPY_AND_ASSIGN(MediaPlayersObserver);
};
} // namespace content
#endif // CONTENT_BROWSER_ANDROID_MEDIA_PLAYERS_OBSERVER_H_
|