Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / content / renderer / media / android / renderer_demuxer_android.h
blob29469edebb600d77a66963618d54979f6ad8177e
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_RENDERER_MEDIA_ANDROID_RENDERER_DEMUXER_ANDROID_H_
6 #define CONTENT_RENDERER_MEDIA_ANDROID_RENDERER_DEMUXER_ANDROID_H_
8 #include "base/atomic_sequence_num.h"
9 #include "base/id_map.h"
10 #include "ipc/message_filter.h"
11 #include "media/base/android/demuxer_stream_player_params.h"
13 namespace base {
14 class SingleThreadTaskRunner;
17 namespace content {
19 class MediaSourceDelegate;
20 class ThreadSafeSender;
22 // Represents the renderer process half of an IPC-based implementation of
23 // media::DemuxerAndroid.
25 // Refer to BrowserDemuxerAndroid for the browser process half.
26 class RendererDemuxerAndroid : public IPC::MessageFilter {
27 public:
28 RendererDemuxerAndroid();
30 // Returns the next available demuxer client ID for use in IPC messages.
32 // Safe to call on any thread.
33 int GetNextDemuxerClientID();
35 // Associates |delegate| with |demuxer_client_id| for handling incoming IPC
36 // messages.
38 // Must be called on media thread.
39 void AddDelegate(int demuxer_client_id, MediaSourceDelegate* delegate);
41 // Removes the association created by AddDelegate().
43 // Must be called on media thread.
44 void RemoveDelegate(int demuxer_client_id);
46 // IPC::MessageFilter overrides.
47 bool OnMessageReceived(const IPC::Message& message) override;
49 // media::DemuxerAndroidClient "implementation".
51 // TODO(scherkus): Consider having RendererDemuxerAndroid actually implement
52 // media::DemuxerAndroidClient and MediaSourceDelegate actually implement
53 // media::DemuxerAndroid.
54 void DemuxerReady(int demuxer_client_id,
55 const media::DemuxerConfigs& configs);
56 void ReadFromDemuxerAck(int demuxer_client_id,
57 const media::DemuxerData& data);
58 void DemuxerSeekDone(int demuxer_client_id,
59 const base::TimeDelta& actual_browser_seek_time);
60 void DurationChanged(int demuxer_client_id, const base::TimeDelta& duration);
62 protected:
63 friend class base::RefCountedThreadSafe<RendererDemuxerAndroid>;
64 ~RendererDemuxerAndroid() override;
66 private:
67 void DispatchMessage(const IPC::Message& message);
68 void OnReadFromDemuxer(int demuxer_client_id,
69 media::DemuxerStream::Type type);
70 void OnDemuxerSeekRequest(int demuxer_client_id,
71 const base::TimeDelta& time_to_seek,
72 bool is_browser_seek);
74 base::AtomicSequenceNumber next_demuxer_client_id_;
76 IDMap<MediaSourceDelegate> delegates_;
77 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
78 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_;
80 DISALLOW_COPY_AND_ASSIGN(RendererDemuxerAndroid);
83 } // namespace content
85 #endif // CONTENT_RENDERER_MEDIA_ANDROID_RENDERER_DEMUXER_ANDROID_H_