1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47

media / muxers / mp4_muxer_context.cc [blame]

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "media/muxers/mp4_muxer_context.h"

#include "media/formats/mp4/writable_box_definitions.h"
#include "media/muxers/output_position_tracker.h"

namespace media {

Mp4MuxerContext::Mp4MuxerContext(
    std::unique_ptr<OutputPositionTracker> output_position_tracker)
    : output_position_tracker_(std::move(output_position_tracker)) {}

Mp4MuxerContext::~Mp4MuxerContext() = default;

// Track will be created and inserted to vector whatever arrives at
// Muxer.

void Mp4MuxerContext::SetVideoTrack(Track track) {
  CHECK(!video_track_.has_value());
  CHECK_NE(track.timescale, 0u);

  video_track_ = track;
}

void Mp4MuxerContext::SetAudioTrack(Track track) {
  CHECK(!audio_track_.has_value());
  CHECK_NE(track.timescale, 0u);

  audio_track_ = track;
}

std::optional<Mp4MuxerContext::Track> Mp4MuxerContext::GetVideoTrack() const {
  return video_track_;
}

std::optional<Mp4MuxerContext::Track> Mp4MuxerContext::GetAudioTrack() const {
  return audio_track_;
}

OutputPositionTracker& Mp4MuxerContext::GetOutputPositionTracker() const {
  return *output_position_tracker_;
}

}  // namespace media