From 65fee065995fdb01c01b5ca4f3b88721d98c13c7 Mon Sep 17 00:00:00 2001 From: Tom Finegan Date: Fri, 26 Aug 2016 21:07:27 -0700 Subject: [PATCH] mkvmuxer_sample: Add support for Projection element. Part of the Spherical Video V2 draft specification: https://github.com/google/spatial-media/blob/master/docs/spherical-video-v2-rfc.md Change-Id: If8cc7a102933ca7fe81990919dbabe7db97812f8 --- mkvmuxer/mkvmuxer.cc | 1 - mkvmuxer_sample.cc | 30 ++++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/mkvmuxer/mkvmuxer.cc b/mkvmuxer/mkvmuxer.cc index 3a148f3..c34a653 100644 --- a/mkvmuxer/mkvmuxer.cc +++ b/mkvmuxer/mkvmuxer.cc @@ -1530,7 +1530,6 @@ uint64_t VideoTrack::VideoPayloadSize() const { static_cast(frame_rate_)); if (colour_) size += colour_->ColourSize(); - if (projection_) size += projection_->ProjectionSize(); diff --git a/mkvmuxer_sample.cc b/mkvmuxer_sample.cc index 495af46..813cb0c 100644 --- a/mkvmuxer_sample.cc +++ b/mkvmuxer_sample.cc @@ -404,6 +404,36 @@ int main(int argc, char* argv[]) { return EXIT_FAILURE; } + if (pVideoTrack->GetProjection()) { + mkvmuxer::Projection muxer_projection; + const mkvparser::Projection* const parser_projection = + pVideoTrack->GetProjection(); + typedef mkvmuxer::Projection::ProjectionType MuxerProjType; + const int kTypeNotPresent = mkvparser::Projection::kTypeNotPresent; + if (parser_projection->type != kTypeNotPresent) { + muxer_projection.set_type( + static_cast(parser_projection->type)); + } + if (parser_projection->private_data && + parser_projection->private_data_length > 0) { + if (!muxer_projection.SetProjectionPrivate( + parser_projection->private_data, + parser_projection->private_data_length)) { + return EXIT_FAILURE; + } + } + + const float kValueNotPresent = mkvparser::Projection::kValueNotPresent; + if (parser_projection->pose_yaw != kValueNotPresent) + muxer_projection.set_pose_yaw(parser_projection->pose_yaw); + if (parser_projection->pose_pitch != kValueNotPresent) + muxer_projection.set_pose_pitch(parser_projection->pose_pitch); + if (parser_projection->pose_roll != kValueNotPresent) + muxer_projection.set_pose_roll(parser_projection->pose_roll); + if (!video->SetProjection(muxer_projection)) + return EXIT_FAILURE; + } + if (track_name) video->set_name(track_name);