2014-02-03 17:49:21 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#if !defined(MediaInfo_h)
|
|
|
|
#define MediaInfo_h
|
|
|
|
|
|
|
|
#include "nsSize.h"
|
|
|
|
#include "nsRect.h"
|
|
|
|
#include "ImageTypes.h"
|
2014-07-03 20:55:06 -07:00
|
|
|
#include "nsString.h"
|
2014-02-03 17:49:21 -08:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2014-07-03 20:55:06 -07:00
|
|
|
struct TrackInfo {
|
|
|
|
void Init(const nsAString& aId,
|
|
|
|
const nsAString& aKind,
|
|
|
|
const nsAString& aLabel,
|
|
|
|
const nsAString& aLanguage,
|
|
|
|
bool aEnabled)
|
|
|
|
{
|
|
|
|
mId = aId;
|
|
|
|
mKind = aKind;
|
|
|
|
mLabel = aLabel;
|
|
|
|
mLanguage = aLanguage;
|
|
|
|
mEnabled = aEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsString mId;
|
|
|
|
nsString mKind;
|
|
|
|
nsString mLabel;
|
|
|
|
nsString mLanguage;
|
|
|
|
bool mEnabled;
|
|
|
|
};
|
|
|
|
|
2014-02-03 17:49:21 -08:00
|
|
|
// Stores info relevant to presenting media frames.
|
|
|
|
class VideoInfo {
|
|
|
|
public:
|
|
|
|
VideoInfo()
|
|
|
|
: mDisplay(0,0)
|
|
|
|
, mStereoMode(StereoMode::MONO)
|
|
|
|
, mHasVideo(false)
|
2014-07-03 20:55:06 -07:00
|
|
|
{
|
|
|
|
// TODO: TrackInfo should be initialized by its specific codec decoder.
|
|
|
|
// This following call should be removed once we have that implemented.
|
|
|
|
mTrackInfo.Init(NS_LITERAL_STRING("2"), NS_LITERAL_STRING("main"),
|
|
|
|
EmptyString(), EmptyString(), true);
|
|
|
|
}
|
2014-02-03 17:49:21 -08:00
|
|
|
|
|
|
|
// Size in pixels at which the video is rendered. This is after it has
|
|
|
|
// been scaled by its aspect ratio.
|
|
|
|
nsIntSize mDisplay;
|
|
|
|
|
|
|
|
// Indicates the frame layout for single track stereo videos.
|
|
|
|
StereoMode mStereoMode;
|
|
|
|
|
|
|
|
// True if we have an active video bitstream.
|
|
|
|
bool mHasVideo;
|
2014-07-03 20:55:06 -07:00
|
|
|
|
|
|
|
TrackInfo mTrackInfo;
|
2014-02-03 17:49:21 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
class AudioInfo {
|
|
|
|
public:
|
|
|
|
AudioInfo()
|
|
|
|
: mRate(44100)
|
|
|
|
, mChannels(2)
|
|
|
|
, mHasAudio(false)
|
2014-07-03 20:55:06 -07:00
|
|
|
{
|
|
|
|
// TODO: TrackInfo should be initialized by its specific codec decoder.
|
|
|
|
// This following call should be removed once we have that implemented.
|
|
|
|
mTrackInfo.Init(NS_LITERAL_STRING("1"), NS_LITERAL_STRING("main"),
|
|
|
|
EmptyString(), EmptyString(), true);
|
|
|
|
}
|
2014-02-03 17:49:21 -08:00
|
|
|
|
|
|
|
// Sample rate.
|
|
|
|
uint32_t mRate;
|
|
|
|
|
|
|
|
// Number of audio channels.
|
|
|
|
uint32_t mChannels;
|
|
|
|
|
|
|
|
// True if we have an active audio bitstream.
|
|
|
|
bool mHasAudio;
|
2014-07-03 20:55:06 -07:00
|
|
|
|
|
|
|
TrackInfo mTrackInfo;
|
2014-02-03 17:49:21 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
class MediaInfo {
|
|
|
|
public:
|
|
|
|
bool HasVideo() const
|
|
|
|
{
|
|
|
|
return mVideo.mHasVideo;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool HasAudio() const
|
|
|
|
{
|
|
|
|
return mAudio.mHasAudio;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool HasValidMedia() const
|
|
|
|
{
|
|
|
|
return HasVideo() || HasAudio();
|
|
|
|
}
|
|
|
|
|
2014-07-03 20:55:06 -07:00
|
|
|
// TODO: Store VideoInfo and AudioIndo in arrays to support multi-tracks.
|
2014-02-03 17:49:21 -08:00
|
|
|
VideoInfo mVideo;
|
|
|
|
AudioInfo mAudio;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // MediaInfo_h
|