• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef CONTENT_BROWSER_MEDIA_ANDROID_BROWSER_DEMUXER_ANDROID_H_
6 #define CONTENT_BROWSER_MEDIA_ANDROID_BROWSER_DEMUXER_ANDROID_H_
7 
8 #include "base/id_map.h"
9 #include "content/public/browser/browser_message_filter.h"
10 #include "media/base/android/demuxer_android.h"
11 
12 namespace content {
13 
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.
17 //
18 // Refer to RendererDemuxerAndroid for the renderer process half.
19 class CONTENT_EXPORT BrowserDemuxerAndroid : public BrowserMessageFilter {
20  public:
21   BrowserDemuxerAndroid();
22 
23   // BrowserMessageFilter overrides.
24   virtual void OverrideThreadForMessage(const IPC::Message& message,
25                                         BrowserThread::ID* thread) OVERRIDE;
26   virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
27 
28   // Returns an uninitialized demuxer implementation associated with
29   // |demuxer_client_id|, which can be used to communicate with the real demuxer
30   // in the renderer process.
31   scoped_ptr<media::DemuxerAndroid> CreateDemuxer(int demuxer_client_id);
32 
33  protected:
34   friend class base::RefCountedThreadSafe<BrowserDemuxerAndroid>;
35   virtual ~BrowserDemuxerAndroid();
36 
37  private:
38   class Internal;
39 
40   // Called by internal demuxer implementations to add/remove a client
41   // association.
42   void AddDemuxerClient(int demuxer_client_id,
43                         media::DemuxerAndroidClient* client);
44   void RemoveDemuxerClient(int demuxer_client_id);
45 
46   // IPC message handlers.
47   void OnDemuxerReady(int demuxer_client_id,
48                       const media::DemuxerConfigs& configs);
49   void OnReadFromDemuxerAck(int demuxer_client_id,
50                             const media::DemuxerData& data);
51   void OnDemuxerSeekDone(int demuxer_client_id,
52                          const base::TimeDelta& actual_browser_seek_time);
53   void OnDurationChanged(int demuxer_client_id,
54                          const base::TimeDelta& duration);
55 
56   IDMap<media::DemuxerAndroidClient> demuxer_clients_;
57 
58   DISALLOW_COPY_AND_ASSIGN(BrowserDemuxerAndroid);
59 };
60 
61 }  // namespace content
62 
63 #endif  // CONTENT_BROWSER_MEDIA_ANDROID_BROWSER_DEMUXER_ANDROID_H_
64