content/media/encoder/fmp4_muxer/ISOTrackMetadata.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 4 * You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef ISOTrackMetadata_h_
michael@0 7 #define ISOTrackMetadata_h_
michael@0 8
michael@0 9 #include "TrackMetadataBase.h"
michael@0 10
michael@0 11 namespace mozilla {
michael@0 12
michael@0 13 class AACTrackMetadata : public AudioTrackMetadata {
michael@0 14 public:
michael@0 15 // AudioTrackMetadata members
michael@0 16 uint32_t GetAudioFrameDuration() MOZ_OVERRIDE { return mFrameDuration; }
michael@0 17 uint32_t GetAudioFrameSize() MOZ_OVERRIDE { return mFrameSize; }
michael@0 18 uint32_t GetAudioSampleRate() MOZ_OVERRIDE { return mSampleRate; }
michael@0 19 uint32_t GetAudioChannels() MOZ_OVERRIDE { return mChannels; }
michael@0 20
michael@0 21 // TrackMetadataBase member
michael@0 22 MetadataKind GetKind() const MOZ_OVERRIDE { return METADATA_AAC; }
michael@0 23
michael@0 24 // AACTrackMetadata members
michael@0 25 AACTrackMetadata()
michael@0 26 : mSampleRate(0)
michael@0 27 , mFrameDuration(0)
michael@0 28 , mFrameSize(0)
michael@0 29 , mChannels(0) {
michael@0 30 MOZ_COUNT_CTOR(AACTrackMetadata);
michael@0 31 }
michael@0 32 ~AACTrackMetadata() { MOZ_COUNT_DTOR(AACTrackMetadata); }
michael@0 33
michael@0 34 uint32_t mSampleRate; // From 14496-3 table 1.16, it could be 7350 ~ 96000.
michael@0 35 uint32_t mFrameDuration; // Audio frame duration based on SampleRate.
michael@0 36 uint32_t mFrameSize; // Audio frame size, 0 is variant size.
michael@0 37 uint32_t mChannels; // Channel number, it should be 1 or 2.
michael@0 38 };
michael@0 39
michael@0 40 // AVC clock rate is 90k Hz.
michael@0 41 #define AVC_CLOCK_RATE 90000
michael@0 42
michael@0 43 class AVCTrackMetadata : public VideoTrackMetadata {
michael@0 44 public:
michael@0 45 // VideoTrackMetadata members
michael@0 46 uint32_t GetVideoHeight() MOZ_OVERRIDE { return mHeight; }
michael@0 47 uint32_t GetVideoWidth() MOZ_OVERRIDE {return mWidth; }
michael@0 48 uint32_t GetVideoDisplayHeight() MOZ_OVERRIDE { return mDisplayHeight; }
michael@0 49 uint32_t GetVideoDisplayWidth() MOZ_OVERRIDE { return mDisplayWidth; }
michael@0 50 uint32_t GetVideoClockRate() MOZ_OVERRIDE { return AVC_CLOCK_RATE; }
michael@0 51 uint32_t GetVideoFrameRate() MOZ_OVERRIDE { return mFrameRate; }
michael@0 52
michael@0 53 // TrackMetadataBase member
michael@0 54 MetadataKind GetKind() const MOZ_OVERRIDE { return METADATA_AVC; }
michael@0 55
michael@0 56 // AVCTrackMetadata
michael@0 57 AVCTrackMetadata()
michael@0 58 : mHeight(0)
michael@0 59 , mWidth(0)
michael@0 60 , mDisplayHeight(0)
michael@0 61 , mDisplayWidth(0)
michael@0 62 , mFrameRate(0) {
michael@0 63 MOZ_COUNT_CTOR(AVCTrackMetadata);
michael@0 64 }
michael@0 65 ~AVCTrackMetadata() { MOZ_COUNT_DTOR(AVCTrackMetadata); }
michael@0 66
michael@0 67 uint32_t mHeight;
michael@0 68 uint32_t mWidth;
michael@0 69 uint32_t mDisplayHeight;
michael@0 70 uint32_t mDisplayWidth;
michael@0 71 uint32_t mFrameRate; // frames per second
michael@0 72 };
michael@0 73
michael@0 74
michael@0 75 // AMR sample rate is 8000 samples/s.
michael@0 76 #define AMR_SAMPLE_RATE 8000
michael@0 77
michael@0 78 // Channel number is always 1.
michael@0 79 #define AMR_CHANNELS 1
michael@0 80
michael@0 81 // AMR speech codec, 3GPP TS 26.071. Encoder and continer support AMR-NB only
michael@0 82 // currently.
michael@0 83 class AMRTrackMetadata : public AudioTrackMetadata {
michael@0 84 public:
michael@0 85 // AudioTrackMetadata members
michael@0 86 //
michael@0 87 // The number of sample sets generates by encoder is variant. So the
michael@0 88 // frame duration and frame size are both 0.
michael@0 89 uint32_t GetAudioFrameDuration() MOZ_OVERRIDE { return 0; }
michael@0 90 uint32_t GetAudioFrameSize() MOZ_OVERRIDE { return 0; }
michael@0 91 uint32_t GetAudioSampleRate() MOZ_OVERRIDE { return AMR_SAMPLE_RATE; }
michael@0 92 uint32_t GetAudioChannels() MOZ_OVERRIDE { return AMR_CHANNELS; }
michael@0 93
michael@0 94 // TrackMetadataBase member
michael@0 95 MetadataKind GetKind() const MOZ_OVERRIDE { return METADATA_AMR; }
michael@0 96
michael@0 97 // AMRTrackMetadata members
michael@0 98 AMRTrackMetadata() { MOZ_COUNT_CTOR(AMRTrackMetadata); }
michael@0 99 ~AMRTrackMetadata() { MOZ_COUNT_DTOR(AMRTrackMetadata); }
michael@0 100 };
michael@0 101
michael@0 102 }
michael@0 103
michael@0 104 #endif // ISOTrackMetadata_h_

mercurial