OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_FORMATS_MP2T_ES_PARSER_H264_H_ | 5 #ifndef MEDIA_FORMATS_MP2T_ES_PARSER_H264_H_ |
6 #define MEDIA_FORMATS_MP2T_ES_PARSER_H264_H_ | 6 #define MEDIA_FORMATS_MP2T_ES_PARSER_H264_H_ |
7 | 7 |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "media/base/media_export.h" | 15 #include "media/base/media_export.h" |
| 16 #include "media/base/ranges.h" |
16 #include "media/base/video_decoder_config.h" | 17 #include "media/base/video_decoder_config.h" |
17 #include "media/formats/mp2t/es_adapter_video.h" | 18 #include "media/formats/mp2t/es_adapter_video.h" |
18 #include "media/formats/mp2t/es_parser.h" | 19 #include "media/formats/mp2t/es_parser.h" |
19 | 20 |
20 namespace media { | 21 namespace media { |
21 class H264Parser; | 22 class H264Parser; |
22 struct H264SPS; | 23 struct H264SPS; |
23 class OffsetByteQueue; | 24 class OffsetByteQueue; |
24 } | 25 } |
25 | 26 |
26 namespace media { | 27 namespace media { |
27 namespace mp2t { | 28 namespace mp2t { |
28 | 29 |
29 // A few remarks: | 30 // A few remarks: |
30 // - In this h264 parser, frame splitting is based on AUD nals. | 31 // - In this h264 parser, frame splitting is based on AUD nals. |
31 // Mpeg2 TS spec: "2.14 Carriage of Rec. ITU-T H.264 | ISO/IEC 14496-10 video" | 32 // Mpeg2 TS spec: "2.14 Carriage of Rec. ITU-T H.264 | ISO/IEC 14496-10 video" |
32 // "Each AVC access unit shall contain an access unit delimiter NAL Unit;" | 33 // "Each AVC access unit shall contain an access unit delimiter NAL Unit;" |
33 // - PES packets do not necessarily map to an H264 access unit although the HLS | 34 // - PES packets do not necessarily map to an H264 access unit although the HLS |
34 // recommendation is to use one PES for each access unit. In this parser, | 35 // recommendation is to use one PES for each access unit. In this parser, |
35 // we handle the general case and do not make any assumption about the access | 36 // we handle the general case and do not make any assumption about the access |
36 // unit organization within PES packets. | 37 // unit organization within PES packets. |
37 // | 38 // |
38 class MEDIA_EXPORT EsParserH264 : public EsParser { | 39 class MEDIA_EXPORT EsParserH264 : public EsParser { |
39 public: | 40 public: |
40 typedef base::Callback<void(const VideoDecoderConfig&)> NewVideoConfigCB; | 41 typedef base::Callback<void(const VideoDecoderConfig&)> NewVideoConfigCB; |
41 | 42 |
42 EsParserH264(const NewVideoConfigCB& new_video_config_cb, | 43 EsParserH264(const NewVideoConfigCB& new_video_config_cb, |
43 const EmitBufferCB& emit_buffer_cb); | 44 const EmitBufferCB& emit_buffer_cb); |
| 45 #ifdef ENABLE_HLS_SAMPLE_AES |
| 46 EsParserH264(const NewVideoConfigCB& new_video_config_cb, |
| 47 const EmitBufferCB& emit_buffer_cb, |
| 48 const GetDecryptConfigCB& get_decrypt_config_cb, |
| 49 bool use_hls_sample_aes); |
| 50 #endif |
44 ~EsParserH264() override; | 51 ~EsParserH264() override; |
45 | 52 |
46 // EsParser implementation. | 53 // EsParser implementation. |
47 void Flush() override; | 54 void Flush() override; |
48 | 55 |
49 private: | 56 private: |
50 // EsParser implementation. | 57 // EsParser implementation. |
51 bool ParseFromEsQueue() override; | 58 bool ParseFromEsQueue() override; |
52 void ResetInternal() override; | 59 void ResetInternal() override; |
53 | 60 |
(...skipping 15 matching lines...) Expand all Loading... |
69 const EncryptionScheme& scheme); | 76 const EncryptionScheme& scheme); |
70 | 77 |
71 EsAdapterVideo es_adapter_; | 78 EsAdapterVideo es_adapter_; |
72 | 79 |
73 // H264 parser state. | 80 // H264 parser state. |
74 // - |current_access_unit_pos_| is pointing to an annexB syncword | 81 // - |current_access_unit_pos_| is pointing to an annexB syncword |
75 // representing the first NALU of an H264 access unit. | 82 // representing the first NALU of an H264 access unit. |
76 scoped_ptr<H264Parser> h264_parser_; | 83 scoped_ptr<H264Parser> h264_parser_; |
77 int64 current_access_unit_pos_; | 84 int64 current_access_unit_pos_; |
78 int64 next_access_unit_pos_; | 85 int64 next_access_unit_pos_; |
| 86 #ifdef ENABLE_HLS_SAMPLE_AES |
| 87 Ranges<int> protected_blocks_; |
| 88 // Callback to obtain the current decrypt_config. |
| 89 // Only called if use_hls_sample_aes_ is true. |
| 90 GetDecryptConfigCB get_decrypt_config_cb_; |
| 91 bool use_hls_sample_aes_; |
| 92 #endif |
79 | 93 |
80 // Last video decoder config. | 94 // Last video decoder config. |
81 VideoDecoderConfig last_video_decoder_config_; | 95 VideoDecoderConfig last_video_decoder_config_; |
82 | 96 |
83 DISALLOW_COPY_AND_ASSIGN(EsParserH264); | 97 DISALLOW_COPY_AND_ASSIGN(EsParserH264); |
84 }; | 98 }; |
85 | 99 |
86 } // namespace mp2t | 100 } // namespace mp2t |
87 } // namespace media | 101 } // namespace media |
88 | 102 |
89 #endif | 103 #endif |
OLD | NEW |