2015-10-08 21:48:07 +00:00
|
|
|
// Copyright 2014 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2017-12-20 00:56:36 +00:00
|
|
|
#ifndef PACKAGER_MEDIA_FORMATS_WEBM_WEBM_VIDEO_CLIENT_H_
|
|
|
|
#define PACKAGER_MEDIA_FORMATS_WEBM_WEBM_VIDEO_CLIENT_H_
|
2015-10-08 21:48:07 +00:00
|
|
|
|
2016-08-17 17:41:40 +00:00
|
|
|
#include <memory>
|
2015-10-08 21:48:07 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2023-10-14 16:36:01 +00:00
|
|
|
#include <packager/macros/classes.h>
|
2023-10-10 23:51:11 +00:00
|
|
|
#include <packager/media/base/video_stream_info.h>
|
|
|
|
#include <packager/media/codecs/vp_codec_configuration_record.h>
|
|
|
|
#include <packager/media/formats/webm/webm_parser.h>
|
2015-10-08 21:48:07 +00:00
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
namespace shaka {
|
2015-10-08 21:48:07 +00:00
|
|
|
namespace media {
|
|
|
|
class VideoDecoderConfig;
|
|
|
|
|
2015-10-15 22:39:16 +00:00
|
|
|
/// Helper class used to parse a Video element inside a TrackEntry element.
|
2015-10-08 21:48:07 +00:00
|
|
|
class WebMVideoClient : public WebMParserClient {
|
|
|
|
public:
|
2015-10-14 22:46:23 +00:00
|
|
|
WebMVideoClient();
|
2015-10-08 21:48:07 +00:00
|
|
|
~WebMVideoClient() override;
|
|
|
|
|
2015-10-15 22:39:16 +00:00
|
|
|
/// Reset this object's state so it can process a new video track element.
|
2015-10-08 21:48:07 +00:00
|
|
|
void Reset();
|
|
|
|
|
2015-10-15 22:39:16 +00:00
|
|
|
/// Create a VideoStreamInfo with the data in |track_num|, |codec_id|,
|
2018-08-25 02:04:00 +00:00
|
|
|
/// |codec_private|, |is_encrypted| and the fields parsed from the last video
|
|
|
|
/// track element this object was used to parse.
|
2017-01-24 00:55:02 +00:00
|
|
|
/// @return A VideoStreamInfo if successful.
|
|
|
|
/// @return An empty pointer if there was unexpected values in the
|
2015-10-15 22:39:16 +00:00
|
|
|
/// provided parameters or video track element fields.
|
2017-01-24 00:55:02 +00:00
|
|
|
std::shared_ptr<VideoStreamInfo> GetVideoStreamInfo(
|
2015-10-14 23:12:10 +00:00
|
|
|
int64_t track_num,
|
|
|
|
const std::string& codec_id,
|
2018-08-25 02:04:00 +00:00
|
|
|
const std::vector<uint8_t>& codec_private,
|
2015-10-14 23:12:10 +00:00
|
|
|
bool is_encrypted);
|
2015-10-08 21:48:07 +00:00
|
|
|
|
2017-04-25 19:02:08 +00:00
|
|
|
/// Extracts VPCodecConfigurationRecord parsed from codec private data and
|
|
|
|
/// Colour element.
|
2017-10-06 18:14:40 +00:00
|
|
|
VPCodecConfigurationRecord GetVpCodecConfig(
|
2017-04-25 19:02:08 +00:00
|
|
|
const std::vector<uint8_t>& codec_private);
|
|
|
|
|
2015-10-08 21:48:07 +00:00
|
|
|
private:
|
|
|
|
// WebMParserClient implementation.
|
2017-04-25 19:02:08 +00:00
|
|
|
WebMParserClient* OnListStart(int id) override;
|
|
|
|
bool OnListEnd(int id) override;
|
2015-10-14 22:46:23 +00:00
|
|
|
bool OnUInt(int id, int64_t val) override;
|
|
|
|
bool OnBinary(int id, const uint8_t* data, int size) override;
|
2015-10-08 21:48:07 +00:00
|
|
|
bool OnFloat(int id, double val) override;
|
|
|
|
|
2017-10-06 18:14:40 +00:00
|
|
|
int64_t pixel_width_ = -1;
|
|
|
|
int64_t pixel_height_ = -1;
|
|
|
|
int64_t crop_bottom_ = -1;
|
|
|
|
int64_t crop_top_ = -1;
|
|
|
|
int64_t crop_left_ = -1;
|
|
|
|
int64_t crop_right_ = -1;
|
|
|
|
int64_t display_width_ = -1;
|
|
|
|
int64_t display_height_ = -1;
|
|
|
|
int64_t display_unit_ = -1;
|
|
|
|
int64_t alpha_mode_ = -1;
|
2015-10-08 21:48:07 +00:00
|
|
|
|
2017-10-06 18:14:40 +00:00
|
|
|
int64_t matrix_coefficients_ = -1;
|
|
|
|
int64_t bits_per_channel_ = -1;
|
|
|
|
int64_t chroma_subsampling_horz_ = -1;
|
|
|
|
int64_t chroma_subsampling_vert_ = -1;
|
|
|
|
int64_t chroma_siting_horz_ = -1;
|
|
|
|
int64_t chroma_siting_vert_ = -1;
|
|
|
|
int64_t color_range_ = -1;
|
|
|
|
int64_t transfer_characteristics_ = -1;
|
|
|
|
int64_t color_primaries_ = -1;
|
2017-04-25 19:02:08 +00:00
|
|
|
|
2015-10-08 21:48:07 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(WebMVideoClient);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace media
|
2016-05-20 21:19:33 +00:00
|
|
|
} // namespace shaka
|
2015-10-08 21:48:07 +00:00
|
|
|
|
2017-12-20 00:56:36 +00:00
|
|
|
#endif // PACKAGER_MEDIA_FORMATS_WEBM_WEBM_VIDEO_CLIENT_H_
|