| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_COMMON_GPU_MEDIA_AVC_CONFIG_RECORD_BUILDER_H_ | |
| 6 #define CONTENT_COMMON_GPU_MEDIA_AVC_CONFIG_RECORD_BUILDER_H_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "base/memory/ref_counted.h" | |
| 11 #include "base/memory/ref_counted_memory.h" | |
| 12 #include "content/common/content_export.h" | |
| 13 | |
| 14 namespace content { | |
| 15 | |
| 16 struct H264NALU; | |
| 17 class H264Parser; | |
| 18 | |
| 19 // Utility class to build an AVC configuration record given a stream of NALUs | |
| 20 // containing SPS and PPS data. | |
| 21 class CONTENT_EXPORT AVCConfigRecordBuilder { | |
| 22 public: | |
| 23 AVCConfigRecordBuilder(); | |
| 24 ~AVCConfigRecordBuilder(); | |
| 25 | |
| 26 // Processes the given NALU. If the final AVC decoder configuration record | |
| 27 // can be built then the NALU is not consumed and the record is returned | |
| 28 // in |config_record|. Otherwise the NALU is consumed and |config_record| | |
| 29 // is not modified. Returns true on success, false on failure. | |
| 30 bool ProcessNALU(H264Parser* parser, | |
| 31 const H264NALU& nalu, | |
| 32 std::vector<uint8>* config_record); | |
| 33 | |
| 34 int coded_width() const { return coded_width_; } | |
| 35 int coded_height() const { return coded_height_; } | |
| 36 | |
| 37 private: | |
| 38 typedef std::vector<scoped_refptr<base::RefCountedBytes> > NALUVector; | |
| 39 | |
| 40 bool ProcessSPS(H264Parser* parser, const H264NALU& nalu); | |
| 41 bool ProcessPPS(H264Parser* parser, const H264NALU& nalu); | |
| 42 bool BuildConfigRecord(std::vector<uint8>* config_record); | |
| 43 | |
| 44 // Copies data from |nalus| into |record_buffer|. Returns the number of bytes | |
| 45 // that were written. | |
| 46 size_t CopyNALUsToConfigRecord(const NALUVector& nalus, uint8* record_buffer); | |
| 47 | |
| 48 // Data for each SPS. | |
| 49 NALUVector sps_nalus_; | |
| 50 // Data for each PPS. | |
| 51 NALUVector pps_nalus_; | |
| 52 // The video codec profile stored in the SPS. | |
| 53 int sps_profile_idc_; | |
| 54 // The constraint setx flags stored in the SPS. | |
| 55 int sps_constraint_setx_flag_; | |
| 56 // The avc level stored in the SPS. | |
| 57 int sps_level_idc_; | |
| 58 // The width of the video as enocded in the SPS. | |
| 59 uint32 coded_width_; | |
| 60 // The height of the video as enocded in the SPS. | |
| 61 uint32 coded_height_; | |
| 62 }; | |
| 63 | |
| 64 } // namespace content | |
| 65 | |
| 66 #endif // CONTENT_COMMON_GPU_MEDIA_AVC_CONFIG_RECORD_BUILDER_H_ | |
| OLD | NEW |