| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MEDIA_FILTERS_BLOCKING_URL_PROTOCOL_H_ | 5 #ifndef MEDIA_FILTERS_BLOCKING_URL_PROTOCOL_H_ |
| 6 #define MEDIA_FILTERS_BLOCKING_URL_PROTOCOL_H_ | 6 #define MEDIA_FILTERS_BLOCKING_URL_PROTOCOL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/synchronization/lock.h" |
| 12 #include "base/synchronization/waitable_event.h" | 13 #include "base/synchronization/waitable_event.h" |
| 13 #include "media/filters/ffmpeg_glue.h" | 14 #include "media/filters/ffmpeg_glue.h" |
| 14 | 15 |
| 15 namespace media { | 16 namespace media { |
| 16 | 17 |
| 17 class DataSource; | 18 class DataSource; |
| 18 | 19 |
| 19 // An implementation of FFmpegURLProtocol that blocks until the underlying | 20 // An implementation of FFmpegURLProtocol that blocks until the underlying |
| 20 // asynchronous DataSource::Read() operation completes. | 21 // asynchronous DataSource::Read() operation completes. |
| 21 class MEDIA_EXPORT BlockingUrlProtocol : public FFmpegURLProtocol { | 22 class MEDIA_EXPORT BlockingUrlProtocol : public FFmpegURLProtocol { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 37 bool GetPosition(int64_t* position_out) override; | 38 bool GetPosition(int64_t* position_out) override; |
| 38 bool SetPosition(int64_t position) override; | 39 bool SetPosition(int64_t position) override; |
| 39 bool GetSize(int64_t* size_out) override; | 40 bool GetSize(int64_t* size_out) override; |
| 40 bool IsStreaming() override; | 41 bool IsStreaming() override; |
| 41 | 42 |
| 42 private: | 43 private: |
| 43 // Sets |last_read_bytes_| and signals the blocked thread that the read | 44 // Sets |last_read_bytes_| and signals the blocked thread that the read |
| 44 // has completed. | 45 // has completed. |
| 45 void SignalReadCompleted(int size); | 46 void SignalReadCompleted(int size); |
| 46 | 47 |
| 48 base::Lock data_source_lock_; |
| 47 DataSource* data_source_; | 49 DataSource* data_source_; |
| 48 base::Closure error_cb_; | 50 base::Closure error_cb_; |
| 51 const bool is_streaming_; |
| 49 | 52 |
| 50 // Used to unblock the thread during shutdown and when reads complete. | 53 // Used to unblock the thread during shutdown and when reads complete. |
| 51 base::WaitableEvent aborted_; | 54 base::WaitableEvent aborted_; |
| 52 base::WaitableEvent read_complete_; | 55 base::WaitableEvent read_complete_; |
| 53 | 56 |
| 54 // Cached number of bytes last read from the data source. | 57 // Cached number of bytes last read from the data source. |
| 55 int last_read_bytes_; | 58 int last_read_bytes_; |
| 56 | 59 |
| 57 // Cached position within the data source. | 60 // Cached position within the data source. |
| 58 int64_t read_position_; | 61 int64_t read_position_; |
| 59 | 62 |
| 60 DISALLOW_IMPLICIT_CONSTRUCTORS(BlockingUrlProtocol); | 63 DISALLOW_IMPLICIT_CONSTRUCTORS(BlockingUrlProtocol); |
| 61 }; | 64 }; |
| 62 | 65 |
| 63 } // namespace media | 66 } // namespace media |
| 64 | 67 |
| 65 #endif // MEDIA_FILTERS_BLOCKING_URL_PROTOCOL_H_ | 68 #endif // MEDIA_FILTERS_BLOCKING_URL_PROTOCOL_H_ |
| OLD | NEW |