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, 27 bool* message_was_ok) OVERRIDE; 28 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); 33 34 protected: 35 friend class base::RefCountedThreadSafe<BrowserDemuxerAndroid>; 36 virtual ~BrowserDemuxerAndroid(); 37 38 private: 39 class Internal; 40 41 // Called by internal demuxer implementations to add/remove a client 42 // association. 43 void AddDemuxerClient(int demuxer_client_id, 44 media::DemuxerAndroidClient* client); 45 void RemoveDemuxerClient(int demuxer_client_id); 46 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); 56 57 IDMap<media::DemuxerAndroidClient> demuxer_clients_; 58 59 DISALLOW_COPY_AND_ASSIGN(BrowserDemuxerAndroid); 60 }; 61 62 } // namespace content 63 64 #endif // CONTENT_BROWSER_MEDIA_ANDROID_BROWSER_DEMUXER_ANDROID_H_ 65