mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 831224: Allow update of the media duration, r=padenot
With MP3 streams, the media duration might change after we received new data. This patch adds infrastructure to signal the new duration to the media decoder and state machine. It will also fire an event of type 'durationchange' to the DOM.
This commit is contained in:
parent
0668f3f25a
commit
92f7e9a735
@ -72,6 +72,11 @@ public:
|
||||
// Set the duration of the media in microseconds.
|
||||
virtual void SetMediaDuration(int64_t aDuration) = 0;
|
||||
|
||||
// Sets the duration of the media in microseconds. The MediaDecoder
|
||||
// fires a durationchange event to its owner (e.g., an HTML audio
|
||||
// tag).
|
||||
virtual void UpdateMediaDuration(int64_t aDuration) = 0;
|
||||
|
||||
// Set the media as being seekable or not.
|
||||
virtual void SetMediaSeekable(bool aMediaSeekable) = 0;
|
||||
|
||||
|
@ -1272,6 +1272,12 @@ void MediaDecoder::SetMediaDuration(int64_t aDuration)
|
||||
GetStateMachine()->SetDuration(aDuration);
|
||||
}
|
||||
|
||||
void MediaDecoder::UpdateMediaDuration(int64_t aDuration)
|
||||
{
|
||||
NS_ENSURE_TRUE_VOID(GetStateMachine());
|
||||
GetStateMachine()->UpdateDuration(aDuration);
|
||||
}
|
||||
|
||||
void MediaDecoder::SetMediaSeekable(bool aMediaSeekable) {
|
||||
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
|
||||
MOZ_ASSERT(NS_IsMainThread() || OnDecodeThread());
|
||||
|
@ -506,6 +506,7 @@ public:
|
||||
virtual void SetDuration(double aDuration);
|
||||
|
||||
void SetMediaDuration(int64_t aDuration) MOZ_OVERRIDE;
|
||||
void UpdateMediaDuration(int64_t aDuration) MOZ_OVERRIDE;
|
||||
|
||||
// Set a flag indicating whether seeking is supported
|
||||
virtual void SetMediaSeekable(bool aMediaSeekable) MOZ_OVERRIDE;
|
||||
|
@ -1446,6 +1446,16 @@ void MediaDecoderStateMachine::SetDuration(int64_t aDuration)
|
||||
}
|
||||
}
|
||||
|
||||
void MediaDecoderStateMachine::UpdateDuration(int64_t aDuration)
|
||||
{
|
||||
if (aDuration != GetDuration()) {
|
||||
SetDuration(aDuration);
|
||||
nsCOMPtr<nsIRunnable> event =
|
||||
NS_NewRunnableMethod(mDecoder, &MediaDecoder::DurationChanged);
|
||||
NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
void MediaDecoderStateMachine::SetMediaEndTime(int64_t aEndTime)
|
||||
{
|
||||
NS_ASSERTION(OnDecodeThread(), "Should be on decode thread");
|
||||
|
@ -157,6 +157,10 @@ public:
|
||||
// aEndTime is in microseconds.
|
||||
void SetMediaEndTime(int64_t aEndTime);
|
||||
|
||||
// Called from decode thread to update the duration. Can result in
|
||||
// a durationchangeevent. aDuration is in microseconds.
|
||||
void UpdateDuration(int64_t aDuration);
|
||||
|
||||
// Functions used by assertions to ensure we're calling things
|
||||
// on the appropriate threads.
|
||||
bool OnDecodeThread() const {
|
||||
|
@ -97,6 +97,8 @@ public:
|
||||
|
||||
virtual void SetMediaDuration(int64_t aDuration) MOZ_FINAL MOZ_OVERRIDE;
|
||||
|
||||
virtual void UpdateMediaDuration(int64_t aDuration) MOZ_FINAL MOZ_OVERRIDE;
|
||||
|
||||
virtual void SetMediaSeekable(bool aMediaSeekable) MOZ_OVERRIDE;
|
||||
|
||||
virtual void SetTransportSeekable(bool aTransportSeekable) MOZ_FINAL MOZ_OVERRIDE;
|
||||
@ -214,6 +216,12 @@ BufferDecoder::SetMediaDuration(int64_t aDuration)
|
||||
// ignore
|
||||
}
|
||||
|
||||
void
|
||||
BufferDecoder::UpdateMediaDuration(int64_t aDuration)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
|
||||
void
|
||||
BufferDecoder::SetMediaSeekable(bool aMediaSeekable)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user