| OLD | NEW |
| (Empty) | |
| 1 // Copyright 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_SERVICES_MOJO_SOURCE_BUFFER_SERVICE_H_ |
| 6 #define MEDIA_MOJO_SERVICES_MOJO_SOURCE_BUFFER_SERVICE_H_ |
| 7 |
| 8 #include "media/base/source_buffer.h" |
| 9 #include "media/mojo/interfaces/source_buffer.mojom.h" |
| 10 #include "media/mojo/services/media_mojo_export.h" |
| 11 #include "media/mojo/services/mojo_demuxer_service_context.h" |
| 12 |
| 13 namespace media { |
| 14 |
| 15 class DataBuffer; |
| 16 class MediaTracks; |
| 17 class MojoDataBufferReader; |
| 18 |
| 19 // A mojom::SourceBuffer implementation backed by a media::SourceBuffer. |
| 20 class MEDIA_MOJO_EXPORT MojoSourceBufferService |
| 21 : NON_EXPORTED_BASE(public mojom::SourceBuffer) { |
| 22 public: |
| 23 MojoSourceBufferService(base::WeakPtr<MojoDemuxerServiceContext> context); |
| 24 |
| 25 ~MojoSourceBufferService() final; |
| 26 |
| 27 // mojom::SourceBuffer implementation. |
| 28 void Initialize(mojom::SourceBufferClientAssociatedPtrInfo client, |
| 29 int32_t demuxer_id, |
| 30 mojo::ScopedDataPipeConsumerHandle consumer_handle) final; |
| 31 void AddId(const std::string& id, |
| 32 const std::string& type, |
| 33 const std::string& codecs, |
| 34 const AddIdCallback& callback) final; |
| 35 void AppendData(const std::string& id, |
| 36 mojom::DataBufferPtr mojo_data_buffer, |
| 37 base::TimeDelta append_window_start, |
| 38 base::TimeDelta append_window_end, |
| 39 const AppendDataCallback& callback) final; |
| 40 void SetTracksWatcher(const std::string& id) final; |
| 41 void RemoveId(const std::string& id) final; |
| 42 void GetBufferedRanges(const std::string& id, |
| 43 const GetBufferedRangesCallback& callback) final; |
| 44 void GetHighestPresentationTimestamp( |
| 45 const std::string& id, |
| 46 const GetHighestPresentationTimestampCallback& callback) final; |
| 47 void ResetParserState(const std::string& id, |
| 48 base::TimeDelta append_window_start, |
| 49 base::TimeDelta append_window_end, |
| 50 const ResetParserStateCallback& callback) final; |
| 51 void Remove(const std::string& id, |
| 52 base::TimeDelta start, |
| 53 base::TimeDelta end) final; |
| 54 void EvictCodedFrames(const std::string& id, |
| 55 base::TimeDelta currentMediaTime, |
| 56 size_t newDataSize, |
| 57 const EvictCodedFramesCallback& callback) final; |
| 58 void OnMemoryPressure( |
| 59 base::TimeDelta currentMediaTime, |
| 60 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level, |
| 61 bool force_instant_gc) final; |
| 62 void GetDuration(const GetDurationCallback& callback) final; |
| 63 void GetDuration_Locked(const GetDuration_LockedCallback& callback) final; |
| 64 void SetDuration(double duration) final; |
| 65 void IsParsingMediaSegment( |
| 66 const std::string& id, |
| 67 const IsParsingMediaSegmentCallback& callback) final; |
| 68 void SetSequenceMode(const std::string& id, bool sequence_mode) final; |
| 69 void SetGroupStartTimestampIfInSequenceMode( |
| 70 const std::string& id, |
| 71 base::TimeDelta timestamp_offset) final; |
| 72 void MarkEndOfStream(PipelineStatus status) final; |
| 73 void UnmarkEndOfStream() final; |
| 74 void Shutdown() final; |
| 75 /*void SetMemoryLimitsForTest(DemuxerStream::Type type, size_t memory_limit) |
| 76 final; |
| 77 Ranges<base::TimeDelta> GetBufferedRanges() const final;*/ |
| 78 |
| 79 private: |
| 80 void OnBufferRead(const std::string& id, |
| 81 base::TimeDelta append_window_start, |
| 82 base::TimeDelta append_window_end, |
| 83 const AppendDataCallback& callback, |
| 84 scoped_refptr<media::DataBuffer> buffer); |
| 85 void OnTracksWatcher(const std::string& id, |
| 86 std::unique_ptr<MediaTracks> tracks); |
| 87 |
| 88 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 89 |
| 90 mojom::SourceBufferClientAssociatedPtr client_; |
| 91 |
| 92 base::WeakPtr<MojoDemuxerServiceContext> context_; |
| 93 |
| 94 media::SourceBuffer* source_buffer_; |
| 95 |
| 96 std::unique_ptr<MojoDataBufferReader> mojo_data_buffer_reader_; |
| 97 |
| 98 base::WeakPtrFactory<MojoSourceBufferService> weak_factory_; |
| 99 }; |
| 100 |
| 101 } // namespace media |
| 102 |
| 103 #endif // MEDIA_MOJO_SERVICES_MOJO_SOURCE_BUFFER_SERVICE_H_ |
| OLD | NEW |