Bug 987498 - Part 4 -Implement SetImageSize on DOMHwMediaStream. r=roc

This commit is contained in:
Daosheng Mu 2015-06-15 03:11:00 +02:00
parent 975b25eb83
commit c1ee946cf2
6 changed files with 61 additions and 0 deletions

View File

@ -733,6 +733,42 @@ DOMHwMediaStream::RequestOverlayId()
#endif
}
void
DOMHwMediaStream::SetImageSize(uint32_t width, uint32_t height)
{
#ifdef MOZ_WIDGET_GONK
OverlayImage::Data imgData;
imgData.mOverlayId = mOverlayImage->GetOverlayId();
imgData.mSize = IntSize(width, height);
mOverlayImage->SetData(imgData);
#endif
SourceMediaStream* srcStream = GetStream()->AsSourceStream();
StreamBuffer::Track* track = srcStream->FindTrack(TRACK_VIDEO_PRIMARY);
if (!track || !track->GetSegment()) {
return;
}
#ifdef MOZ_WIDGET_GONK
// Clear the old segment.
// Changing the existing content of segment is a Very BAD thing, and this way will
// confuse consumers of MediaStreams.
// It is only acceptable for DOMHwMediaStream
// because DOMHwMediaStream doesn't have consumers of TV streams currently.
track->GetSegment()->Clear();
// Change the image size.
const StreamTime delta = STREAM_TIME_MAX;
nsRefPtr<Image> image = static_cast<Image*>(mOverlayImage.get());
mozilla::gfx::IntSize size = image->GetSize();
VideoSegment segment;
segment.AppendFrame(image.forget(), delta, size);
srcStream->AppendToTrack(TRACK_VIDEO_PRIMARY, &segment);
#endif
}
void
DOMHwMediaStream::SetOverlayId(int32_t aOverlayId)
{

View File

@ -400,6 +400,7 @@ public:
virtual DOMHwMediaStream* AsDOMHwMediaStream() override { return this; }
int32_t RequestOverlayId();
void SetOverlayId(int32_t aOverlayId);
void SetImageSize(uint32_t width, uint32_t height);
protected:
~DOMHwMediaStream();

View File

@ -2496,6 +2496,12 @@ SourceMediaStream::FinishAddTracks()
}
}
StreamBuffer::Track*
SourceMediaStream::FindTrack(TrackID aID)
{
return mBuffer.FindTrack(aID);
}
void
SourceMediaStream::ResampleAudioToGraphSampleRate(TrackData* aTrackData, MediaSegment* aSegment)
{

View File

@ -801,6 +801,11 @@ public:
*/
void FinishAddTracks();
/**
* Find track by track id.
*/
StreamBuffer::Track* FindTrack(TrackID aID);
/**
* Append media data to a track. Ownership of aSegment remains with the caller,
* but aSegment is emptied.

View File

@ -220,5 +220,17 @@ TVTuner::DispatchCurrentSourceChangedEvent(TVSource* aSource)
return NS_DispatchToCurrentThread(runnable);
}
nsresult
TVTuner::NotifyImageSizeChanged(uint32_t aWidth, uint32_t aHeight)
{
DOMHwMediaStream* hwMediaStream = mStream->AsDOMHwMediaStream();
if (hwMediaStream) {
hwMediaStream->SetImageSize(aWidth, aHeight);
}
return NS_OK;
}
} // namespace dom
} // namespace mozilla

View File

@ -31,6 +31,7 @@ public:
static already_AddRefed<TVTuner> Create(nsPIDOMWindow* aWindow,
nsITVTunerData* aData);
nsresult NotifyImageSizeChanged(uint32_t aWidth, uint32_t aHeight);
// WebIDL (internal functions)