summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/binding/include/mp4_demuxer/MP4Metadata.h
blob: 83eca69d33c40f7af3dfcb41f4e54bb04bf351bf (plain)
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
48
49
50
51
52
53
54
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef MP4METADATA_H_
#define MP4METADATA_H_

#include "mozilla/UniquePtr.h"
#include "mp4_demuxer/DecoderData.h"
#include "mp4_demuxer/Index.h"
#include "MediaData.h"
#include "MediaInfo.h"
#include "Stream.h"

namespace mp4_demuxer
{

class MP4MetadataStagefright;
class MP4MetadataRust;

class MP4Metadata
{
public:
  explicit MP4Metadata(Stream* aSource);
  ~MP4Metadata();

  static bool HasCompleteMetadata(Stream* aSource);
  static already_AddRefed<mozilla::MediaByteBuffer> Metadata(Stream* aSource);
  uint32_t GetNumberTracks(mozilla::TrackInfo::TrackType aType) const;
  mozilla::UniquePtr<mozilla::TrackInfo> GetTrackInfo(mozilla::TrackInfo::TrackType aType,
                                                      size_t aTrackNumber) const;
  bool CanSeek() const;

  const CryptoFile& Crypto() const;

  bool ReadTrackIndex(FallibleTArray<Index::Indice>& aDest, mozilla::TrackID aTrackID);

private:
  UniquePtr<MP4MetadataStagefright> mStagefright;
#ifdef MOZ_RUST_MP4PARSE
  UniquePtr<MP4MetadataRust> mRust;
  mutable bool mPreferRust;
  mutable bool mReportedAudioTrackTelemetry;
  mutable bool mReportedVideoTrackTelemetry;
#ifndef RELEASE_OR_BETA
  mutable bool mRustTestMode;
#endif
  bool ShouldPreferRust() const;
#endif
};

} // namespace mp4_demuxer

#endif // MP4METADATA_H_