| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2017 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 MEDIA_MOJO_CLIENTS_MOJO_DEMUXER_SOURCE_BUFFER_H_ |
| 6 #define MEDIA_MOJO_CLIENTS_MOJO_DEMUXER_SOURCE_BUFFER_H_ |
| 7 |
| 8 #include "media/base/source_buffer.h" |
| 9 #include "media/mojo/clients/mojo_demuxer.h" |
| 10 #include "media/mojo/interfaces/source_buffer.mojom.h" |
| 11 |
| 12 namespace media { |
| 13 |
| 14 class MojoDataBufferWriter; |
| 15 |
| 16 class MojoDemuxerSourceBuffer : public MojoDemuxer, |
| 17 public SourceBuffer, |
| 18 public mojom::SourceBufferClient { |
| 19 public: |
| 20 explicit MojoDemuxerSourceBuffer( |
| 21 int32_t id, |
| 22 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner, |
| 23 const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner, |
| 24 mojom::DemuxerPtr mojo_demuxer, |
| 25 mojom::SourceBufferPtr mojo_source_buffer, |
| 26 const base::Closure& open_cb, |
| 27 const Demuxer::EncryptedMediaInitDataCB& encrypted_media_init_data_cb); |
| 28 ~MojoDemuxerSourceBuffer() override; |
| 29 |
| 30 // Demuxer interface. |
| 31 std::string GetDisplayName() const override; |
| 32 void Initialize(DemuxerHost* host, |
| 33 const PipelineStatusCB& status_cb, |
| 34 bool enable_text_tracks) override; |
| 35 |
| 36 // SourceBuffer interface. |
| 37 SourceBuffer::Status AddId(const std::string& id, |
| 38 const std::string& type, |
| 39 const std::string& codecs) final; |
| 40 void SetTracksWatcher(const std::string& id, |
| 41 const MediaTracksUpdatedCB& tracks_updated_cb) final; |
| 42 void RemoveId(const std::string& id) final; |
| 43 Ranges<base::TimeDelta> GetBufferedRanges(const std::string& id) const final; |
| 44 base::TimeDelta GetHighestPresentationTimestamp( |
| 45 const std::string& id) const final; |
| 46 bool AppendData(const std::string& id, |
| 47 const uint8_t* data, |
| 48 size_t length, |
| 49 base::TimeDelta append_window_start, |
| 50 base::TimeDelta append_window_end, |
| 51 base::TimeDelta* timestamp_offset) final; |
| 52 void ResetParserState(const std::string& id, |
| 53 base::TimeDelta append_window_start, |
| 54 base::TimeDelta append_window_end, |
| 55 base::TimeDelta* timestamp_offset) final; |
| 56 void Remove(const std::string& id, |
| 57 base::TimeDelta start, |
| 58 base::TimeDelta end) final; |
| 59 bool EvictCodedFrames(const std::string& id, |
| 60 base::TimeDelta currentMediaTime, |
| 61 size_t newDataSize) final; |
| 62 void OnMemoryPressure( |
| 63 base::TimeDelta currentMediaTime, |
| 64 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level, |
| 65 bool force_instant_gc) final; |
| 66 double GetDuration() final; |
| 67 double GetDuration_Locked() final; |
| 68 void SetDuration(double duration) final; |
| 69 bool IsParsingMediaSegment(const std::string& id) final; |
| 70 void SetSequenceMode(const std::string& id, bool sequence_mode) final; |
| 71 void SetGroupStartTimestampIfInSequenceMode( |
| 72 const std::string& id, |
| 73 base::TimeDelta timestamp_offset) final; |
| 74 void MarkEndOfStream(PipelineStatus status) final; |
| 75 void UnmarkEndOfStream() final; |
| 76 void Shutdown() final; |
| 77 void SetMemoryLimitsForTest(DemuxerStream::Type type, |
| 78 size_t memory_limit) final; |
| 79 Ranges<base::TimeDelta> GetBufferedRanges() const final; |
| 80 |
| 81 // mojom::SourceBufferClient implementation. |
| 82 void OnTracksWatcher(const std::string& id, |
| 83 mojom::MediaTracksPtr mojo_tracks) final; |
| 84 |
| 85 private: |
| 86 void InitializeInternal(); |
| 87 void OnAddId(SourceBuffer::Status status); |
| 88 void OnAppendData(bool success, base::TimeDelta timestamp_offset); |
| 89 void OnMemoryPressureInternal( |
| 90 base::TimeDelta currentMediaTime, |
| 91 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level, |
| 92 bool force_instant_gc); |
| 93 void OnConnectionError(); |
| 94 void OnMediaTracksDoNothing(std::unique_ptr<MediaTracks> tracks); |
| 95 |
| 96 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
| 97 |
| 98 mojom::SourceBufferPtr remote_source_buffer_; |
| 99 |
| 100 // Binding for SourceBufferClient, bound to the |main_task_runner_|. |
| 101 mojo::AssociatedBinding<SourceBufferClient> client_binding_; |
| 102 |
| 103 double duration_; |
| 104 |
| 105 std::unique_ptr<MojoDataBufferWriter> mojo_data_buffer_writer_; |
| 106 |
| 107 std::map<std::string, MediaTracksUpdatedCB> tracks_updated_callbacks_map_; |
| 108 |
| 109 base::WeakPtrFactory<MojoDemuxerSourceBuffer> weak_factory_; |
| 110 |
| 111 DISALLOW_COPY_AND_ASSIGN(MojoDemuxerSourceBuffer); |
| 112 }; |
| 113 |
| 114 } // namespace media |
| 115 |
| 116 #endif // MEDIA_MOJO_CLIENTS_MOJO_DEMUXER_SOURCE_BUFFER_H_ |
| OLD | NEW |