Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: media/formats/mp2t/es_parser_h264.h

Issue 1517473002: Support HLS MPEG2 TS with SAMPLE-AES encryption. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@encryption_scheme
Patch Set: rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/formats/mp2t/es_parser_adts.cc ('k') | media/formats/mp2t/es_parser_h264.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "media/base/media_export.h" 17 #include "media/base/media_export.h"
18 #include "media/base/ranges.h"
18 #include "media/base/video_decoder_config.h" 19 #include "media/base/video_decoder_config.h"
19 #include "media/formats/mp2t/es_adapter_video.h" 20 #include "media/formats/mp2t/es_adapter_video.h"
20 #include "media/formats/mp2t/es_parser.h" 21 #include "media/formats/mp2t/es_parser.h"
22 #include "media/media_features.h"
21 23
22 namespace media { 24 namespace media {
23 class EncryptionScheme; 25 class EncryptionScheme;
24 class H264Parser; 26 class H264Parser;
25 struct H264SPS; 27 struct H264SPS;
26 } 28 }
27 29
28 namespace media { 30 namespace media {
29 namespace mp2t { 31 namespace mp2t {
30 32
31 // A few remarks: 33 // A few remarks:
32 // - In this h264 parser, frame splitting is based on AUD nals. 34 // - In this h264 parser, frame splitting is based on AUD nals.
33 // Mpeg2 TS spec: "2.14 Carriage of Rec. ITU-T H.264 | ISO/IEC 14496-10 video" 35 // Mpeg2 TS spec: "2.14 Carriage of Rec. ITU-T H.264 | ISO/IEC 14496-10 video"
34 // "Each AVC access unit shall contain an access unit delimiter NAL Unit;" 36 // "Each AVC access unit shall contain an access unit delimiter NAL Unit;"
35 // - PES packets do not necessarily map to an H264 access unit although the HLS 37 // - PES packets do not necessarily map to an H264 access unit although the HLS
36 // recommendation is to use one PES for each access unit. In this parser, 38 // recommendation is to use one PES for each access unit. In this parser,
37 // we handle the general case and do not make any assumption about the access 39 // we handle the general case and do not make any assumption about the access
38 // unit organization within PES packets. 40 // unit organization within PES packets.
39 // 41 //
40 class MEDIA_EXPORT EsParserH264 : public EsParser { 42 class MEDIA_EXPORT EsParserH264 : public EsParser {
41 public: 43 public:
42 typedef base::Callback<void(const VideoDecoderConfig&)> NewVideoConfigCB; 44 typedef base::Callback<void(const VideoDecoderConfig&)> NewVideoConfigCB;
43 45
44 EsParserH264(const NewVideoConfigCB& new_video_config_cb, 46 EsParserH264(const NewVideoConfigCB& new_video_config_cb,
45 const EmitBufferCB& emit_buffer_cb); 47 const EmitBufferCB& emit_buffer_cb);
48 #if BUILDFLAG(ENABLE_HLS_SAMPLE_AES)
49 EsParserH264(const NewVideoConfigCB& new_video_config_cb,
50 const EmitBufferCB& emit_buffer_cb,
51 bool use_hls_sample_aes,
52 const GetDecryptConfigCB& get_decrypt_config_cb);
53 #endif
46 ~EsParserH264() override; 54 ~EsParserH264() override;
47 55
48 // EsParser implementation. 56 // EsParser implementation.
49 void Flush() override; 57 void Flush() override;
50 58
51 private: 59 private:
52 // EsParser implementation. 60 // EsParser implementation.
53 bool ParseFromEsQueue() override; 61 bool ParseFromEsQueue() override;
54 void ResetInternal() override; 62 void ResetInternal() override;
55 63
(...skipping 17 matching lines...) Expand all
73 const EncryptionScheme& scheme); 81 const EncryptionScheme& scheme);
74 82
75 EsAdapterVideo es_adapter_; 83 EsAdapterVideo es_adapter_;
76 84
77 // H264 parser state. 85 // H264 parser state.
78 // - |current_access_unit_pos_| is pointing to an annexB syncword 86 // - |current_access_unit_pos_| is pointing to an annexB syncword
79 // representing the first NALU of an H264 access unit. 87 // representing the first NALU of an H264 access unit.
80 std::unique_ptr<H264Parser> h264_parser_; 88 std::unique_ptr<H264Parser> h264_parser_;
81 int64_t current_access_unit_pos_; 89 int64_t current_access_unit_pos_;
82 int64_t next_access_unit_pos_; 90 int64_t next_access_unit_pos_;
91 #if BUILDFLAG(ENABLE_HLS_SAMPLE_AES)
92 bool use_hls_sample_aes_;
93 // Callback to obtain the current decrypt_config.
94 // Only called if use_hls_sample_aes_ is true.
95 GetDecryptConfigCB get_decrypt_config_cb_;
96 Ranges<int> protected_blocks_;
97 #endif
83 98
84 // Last video decoder config. 99 // Last video decoder config.
85 VideoDecoderConfig last_video_decoder_config_; 100 VideoDecoderConfig last_video_decoder_config_;
86 101
87 DISALLOW_COPY_AND_ASSIGN(EsParserH264); 102 DISALLOW_COPY_AND_ASSIGN(EsParserH264);
88 }; 103 };
89 104
90 } // namespace mp2t 105 } // namespace mp2t
91 } // namespace media 106 } // namespace media
92 107
93 #endif // MEDIA_FORMATS_MP2T_ES_PARSER_H264_H_ 108 #endif // MEDIA_FORMATS_MP2T_ES_PARSER_H264_H_
OLDNEW
« no previous file with comments | « media/formats/mp2t/es_parser_adts.cc ('k') | media/formats/mp2t/es_parser_h264.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698