1 // Copyright 2013 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.
5 #ifndef CONTENT_BROWSER_MEDIA_ANDROID_BROWSER_DEMUXER_ANDROID_H_
6 #define CONTENT_BROWSER_MEDIA_ANDROID_BROWSER_DEMUXER_ANDROID_H_
8 #include "base/id_map.h"
9 #include "content/public/browser/browser_message_filter.h"
10 #include "media/base/android/demuxer_android.h"
14 // Represents the browser process half of an IPC-based demuxer proxy.
15 // It vends out media::DemuxerAndroid instances that are registered with an
16 // end point in the renderer process.
18 // Refer to RendererDemuxerAndroid for the renderer process half.
19 class CONTENT_EXPORT BrowserDemuxerAndroid
: public BrowserMessageFilter
{
21 BrowserDemuxerAndroid();
23 // BrowserMessageFilter overrides.
24 virtual void OverrideThreadForMessage(const IPC::Message
& message
,
25 BrowserThread::ID
* thread
) OVERRIDE
;
26 virtual bool OnMessageReceived(const IPC::Message
& message
,
27 bool* message_was_ok
) OVERRIDE
;
29 // Returns an uninitialized demuxer implementation associated with
30 // |demuxer_client_id|, which can be used to communicate with the real demuxer
31 // in the renderer process.
32 scoped_ptr
<media::DemuxerAndroid
> CreateDemuxer(int demuxer_client_id
);
35 friend class base::RefCountedThreadSafe
<BrowserDemuxerAndroid
>;
36 virtual ~BrowserDemuxerAndroid();
41 // Called by internal demuxer implementations to add/remove a client
43 void AddDemuxerClient(int demuxer_client_id
,
44 media::DemuxerAndroidClient
* client
);
45 void RemoveDemuxerClient(int demuxer_client_id
);
47 // IPC message handlers.
48 void OnDemuxerReady(int demuxer_client_id
,
49 const media::DemuxerConfigs
& configs
);
50 void OnReadFromDemuxerAck(int demuxer_client_id
,
51 const media::DemuxerData
& data
);
52 void OnDemuxerSeekDone(int demuxer_client_id
,
53 const base::TimeDelta
& actual_browser_seek_time
);
54 void OnDurationChanged(int demuxer_client_id
,
55 const base::TimeDelta
& duration
);
57 IDMap
<media::DemuxerAndroidClient
> demuxer_clients_
;
59 DISALLOW_COPY_AND_ASSIGN(BrowserDemuxerAndroid
);
62 } // namespace content
64 #endif // CONTENT_BROWSER_MEDIA_ANDROID_BROWSER_DEMUXER_ANDROID_H_