content/media/MediaInfo.h

Fri, 16 Jan 2015 04:50:19 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 04:50:19 +0100
branch
TOR_BUG_9701
changeset 13
44a2da4a2ab2
permissions
-rw-r--r--

Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32

     1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
     3 /* This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #if !defined(MediaInfo_h)
     7 #define MediaInfo_h
     9 #include "nsSize.h"
    10 #include "nsRect.h"
    11 #include "ImageTypes.h"
    13 namespace mozilla {
    15 // Stores info relevant to presenting media frames.
    16 class VideoInfo {
    17 public:
    18   VideoInfo()
    19     : mDisplay(0,0)
    20     , mStereoMode(StereoMode::MONO)
    21     , mHasVideo(false)
    22   {}
    24   // Size in pixels at which the video is rendered. This is after it has
    25   // been scaled by its aspect ratio.
    26   nsIntSize mDisplay;
    28   // Indicates the frame layout for single track stereo videos.
    29   StereoMode mStereoMode;
    31   // True if we have an active video bitstream.
    32   bool mHasVideo;
    33 };
    35 class AudioInfo {
    36 public:
    37   AudioInfo()
    38     : mRate(44100)
    39     , mChannels(2)
    40     , mHasAudio(false)
    41   {}
    43   // Sample rate.
    44   uint32_t mRate;
    46   // Number of audio channels.
    47   uint32_t mChannels;
    49   // True if we have an active audio bitstream.
    50   bool mHasAudio;
    51 };
    53 class MediaInfo {
    54 public:
    55   bool HasVideo() const
    56   {
    57     return mVideo.mHasVideo;
    58   }
    60   bool HasAudio() const
    61   {
    62     return mAudio.mHasAudio;
    63   }
    65   bool HasValidMedia() const
    66   {
    67     return HasVideo() || HasAudio();
    68   }
    70   VideoInfo mVideo;
    71   AudioInfo mAudio;
    72 };
    74 } // namespace mozilla
    76 #endif // MediaInfo_h

mercurial