1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/media/MediaInfo.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,76 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 +#if !defined(MediaInfo_h) 1.10 +#define MediaInfo_h 1.11 + 1.12 +#include "nsSize.h" 1.13 +#include "nsRect.h" 1.14 +#include "ImageTypes.h" 1.15 + 1.16 +namespace mozilla { 1.17 + 1.18 +// Stores info relevant to presenting media frames. 1.19 +class VideoInfo { 1.20 +public: 1.21 + VideoInfo() 1.22 + : mDisplay(0,0) 1.23 + , mStereoMode(StereoMode::MONO) 1.24 + , mHasVideo(false) 1.25 + {} 1.26 + 1.27 + // Size in pixels at which the video is rendered. This is after it has 1.28 + // been scaled by its aspect ratio. 1.29 + nsIntSize mDisplay; 1.30 + 1.31 + // Indicates the frame layout for single track stereo videos. 1.32 + StereoMode mStereoMode; 1.33 + 1.34 + // True if we have an active video bitstream. 1.35 + bool mHasVideo; 1.36 +}; 1.37 + 1.38 +class AudioInfo { 1.39 +public: 1.40 + AudioInfo() 1.41 + : mRate(44100) 1.42 + , mChannels(2) 1.43 + , mHasAudio(false) 1.44 + {} 1.45 + 1.46 + // Sample rate. 1.47 + uint32_t mRate; 1.48 + 1.49 + // Number of audio channels. 1.50 + uint32_t mChannels; 1.51 + 1.52 + // True if we have an active audio bitstream. 1.53 + bool mHasAudio; 1.54 +}; 1.55 + 1.56 +class MediaInfo { 1.57 +public: 1.58 + bool HasVideo() const 1.59 + { 1.60 + return mVideo.mHasVideo; 1.61 + } 1.62 + 1.63 + bool HasAudio() const 1.64 + { 1.65 + return mAudio.mHasAudio; 1.66 + } 1.67 + 1.68 + bool HasValidMedia() const 1.69 + { 1.70 + return HasVideo() || HasAudio(); 1.71 + } 1.72 + 1.73 + VideoInfo mVideo; 1.74 + AudioInfo mAudio; 1.75 +}; 1.76 + 1.77 +} // namespace mozilla 1.78 + 1.79 +#endif // MediaInfo_h