1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/media/encoder/TrackMetadataBase.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,74 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.7 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef TrackMetadataBase_h_ 1.10 +#define TrackMetadataBase_h_ 1.11 + 1.12 +#include "nsTArray.h" 1.13 +#include "nsCOMPtr.h" 1.14 +namespace mozilla { 1.15 + 1.16 +// A class represent meta data for various codec format. Only support one track information. 1.17 +class TrackMetadataBase 1.18 +{ 1.19 +public: 1.20 + NS_INLINE_DECL_THREADSAFE_REFCOUNTING(TrackMetadataBase) 1.21 + enum MetadataKind { 1.22 + METADATA_OPUS, // Represent the Opus metadata 1.23 + METADATA_VP8, 1.24 + METADATA_VORBIS, 1.25 + METADATA_AVC, 1.26 + METADATA_AAC, 1.27 + METADATA_AMR, 1.28 + METADATA_UNKNOWN // Metadata Kind not set 1.29 + }; 1.30 + // Return the specific metadata kind 1.31 + virtual MetadataKind GetKind() const = 0; 1.32 + 1.33 +protected: 1.34 + // Protected destructor, to discourage deletion outside of Release(): 1.35 + virtual ~TrackMetadataBase() {} 1.36 +}; 1.37 + 1.38 +// The base class for audio metadata. 1.39 +class AudioTrackMetadata : public TrackMetadataBase { 1.40 +public: 1.41 + // The duration of each sample set generated by encoder. (counted by samples) 1.42 + // If the duration is variant, this value should return 0. 1.43 + virtual uint32_t GetAudioFrameDuration() = 0; 1.44 + 1.45 + // The size of each sample set generated by encoder. (counted by byte) 1.46 + // If the size is variant, this value should return 0. 1.47 + virtual uint32_t GetAudioFrameSize() = 0; 1.48 + 1.49 + // AudioSampleRate is the number of audio sample per second. 1.50 + virtual uint32_t GetAudioSampleRate() = 0; 1.51 + 1.52 + virtual uint32_t GetAudioChannels() = 0; 1.53 +}; 1.54 + 1.55 +// The base class for video metadata. 1.56 +class VideoTrackMetadata : public TrackMetadataBase { 1.57 +public: 1.58 + // VideoHeight and VideoWidth are the frame size of the elementary stream. 1.59 + virtual uint32_t GetVideoHeight() = 0; 1.60 + virtual uint32_t GetVideoWidth() = 0; 1.61 + 1.62 + // VideoDisplayHeight and VideoDisplayWidth are the display frame size. 1.63 + virtual uint32_t GetVideoDisplayHeight() = 0; 1.64 + virtual uint32_t GetVideoDisplayWidth() = 0; 1.65 + 1.66 + // VideoClockRate is the number of samples per second in video frame's 1.67 + // timestamp. 1.68 + // For example, if VideoClockRate is 90k Hz and VideoFrameRate is 1.69 + // 30 fps, each frame's sample duration will be 3000 Hz. 1.70 + virtual uint32_t GetVideoClockRate() = 0; 1.71 + 1.72 + // VideoFrameRate is numner of frames per second. 1.73 + virtual uint32_t GetVideoFrameRate() = 0; 1.74 +}; 1.75 + 1.76 +} 1.77 +#endif