tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

TrackMetadataBase.h (2495B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
      2 /* This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
      4 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 #ifndef TrackMetadataBase_h_
      7 #define TrackMetadataBase_h_
      8 
      9 #include "nsCOMPtr.h"
     10 #include "nsTArray.h"
     11 namespace mozilla {
     12 
     13 // A class represent meta data for various codec format. Only support one track
     14 // information.
     15 class TrackMetadataBase {
     16 public:
     17  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(TrackMetadataBase)
     18  enum MetadataKind {
     19    METADATA_OPUS,  // Represent the Opus metadata
     20    METADATA_VP8,
     21    METADATA_VORBIS,
     22    METADATA_AVC,
     23    METADATA_AAC,
     24    METADATA_AMR,
     25    METADATA_EVRC,
     26    METADATA_UNKNOWN  // Metadata Kind not set
     27  };
     28  // Return the specific metadata kind
     29  virtual MetadataKind GetKind() const = 0;
     30 
     31 protected:
     32  // Protected destructor, to discourage deletion outside of Release():
     33  virtual ~TrackMetadataBase() = default;
     34 };
     35 
     36 // The base class for audio metadata.
     37 class AudioTrackMetadata : public TrackMetadataBase {
     38 public:
     39  // The duration of each sample set generated by encoder. (counted by samples)
     40  // If the duration is variant, this value should return 0.
     41  virtual uint32_t GetAudioFrameDuration() = 0;
     42 
     43  // The size of each sample set generated by encoder. (counted by byte)
     44  // If the size is variant, this value should return 0.
     45  virtual uint32_t GetAudioFrameSize() = 0;
     46 
     47  // AudioSampleRate is the number of audio sample per second.
     48  virtual uint32_t GetAudioSampleRate() = 0;
     49 
     50  virtual uint32_t GetAudioChannels() = 0;
     51 };
     52 
     53 // The base class for video metadata.
     54 class VideoTrackMetadata : public TrackMetadataBase {
     55 public:
     56  // VideoHeight and VideoWidth are the frame size of the elementary stream.
     57  virtual uint32_t GetVideoHeight() = 0;
     58  virtual uint32_t GetVideoWidth() = 0;
     59 
     60  // VideoDisplayHeight and VideoDisplayWidth are the display frame size.
     61  virtual uint32_t GetVideoDisplayHeight() = 0;
     62  virtual uint32_t GetVideoDisplayWidth() = 0;
     63 
     64  // VideoClockRate is the number of samples per second in video frame's
     65  // timestamp.
     66  // For example, if VideoClockRate is 90k Hz and VideoFrameRate is
     67  // 30 fps, each frame's sample duration will be 3000 Hz.
     68  virtual uint32_t GetVideoClockRate() = 0;
     69 
     70  // VideoFrameRate is numner of frames per second.
     71  virtual uint32_t GetVideoFrameRate() = 0;
     72 };
     73 
     74 }  // namespace mozilla
     75 
     76 #endif