Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
Implement SourceBuffer::AbortBufferAppend and expose ResetParserState…
Browse files Browse the repository at this point in the history
… through FFI
  • Loading branch information
ferjm committed Dec 21, 2017
1 parent dbdadaa commit 44e1b96
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 4 deletions.
16 changes: 16 additions & 0 deletions gecko-media/gecko/glue/SourceBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,22 @@ SourceBuffer::CheckEndTime()
}
}

void
SourceBuffer::AbortBufferAppend()
{
MOZ_ASSERT(NS_IsMainThread());

if (mCurrentAttributes.GetUpdating()) {
mCompletionPromise.DisconnectIfExists();
if (mPendingAppend.Exists()) {
mPendingAppend.Disconnect();
mTrackBuffersManager->AbortAppendData();
}

mCurrentAttributes.SetUpdating(false);
}
}

void
SourceBuffer::ResetParserState()
{
Expand Down
6 changes: 6 additions & 0 deletions gecko-media/gecko/glue/include/GeckoMediaSourceBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ GeckoMedia_SourceBuffer_AppendData(size_t aId,
void* aSuccessCbContext,
error_callback_t aErrorCb,
void* aErrorCbContext);

void
GeckoMedia_SourceBuffer_AbortBufferAppend(size_t aId);

void
GeckoMedia_SourceBuffer_ResetParserState(size_t aId);
}

#endif // GeckoMediaSourceBuffer_h_
6 changes: 4 additions & 2 deletions gecko-media/gecko/glue/include/SourceBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ class SourceBuffer final
error_callback_t aErrorCb,
void* aErrorCbContext);

void AbortBufferAppend();

void ResetParserState();

private:
friend class MediaSource;

~SourceBuffer(){};

void ResetParserState();

// If the media segment contains data beyond the current duration,
// then run the duration change algorithm with new duration set to the
// maximum of the current duration and the group end timestamp.
Expand Down
20 changes: 18 additions & 2 deletions gecko-media/src/mse/sourcebuffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
// 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/.

use bindings::{GeckoMediaSourceBufferImpl, GeckoMedia_SourceBuffer_Create};
use bindings::{GeckoMedia_SourceBuffer_AppendData, GeckoMedia_SourceBuffer_EvictData};
use bindings::GeckoMediaSourceBufferImpl;
use bindings::GeckoMedia_SourceBuffer_ResetParserState;
use bindings::{GeckoMedia_SourceBuffer_AbortBufferAppend, GeckoMedia_SourceBuffer_AppendData};
use bindings::{GeckoMedia_SourceBuffer_Create, GeckoMedia_SourceBuffer_EvictData};
use std::ffi::CString;
use std::os::raw::c_void;
use std::rc::Rc;
Expand Down Expand Up @@ -80,6 +82,20 @@ impl SourceBuffer {
}

}

pub fn abort_buffer_append(&self) {
let id = self.id;
self.gecko_media.queue_task(move || unsafe {
GeckoMedia_SourceBuffer_AbortBufferAppend(id);
});
}

pub fn reset_parser_state(&self) {
let id = self.id;
self.gecko_media.queue_task(move || unsafe {
GeckoMedia_SourceBuffer_ResetParserState(id);
});
}
}

impl_drop_gecko_media_struct!(SourceBuffer, GeckoMedia_SourceBuffer_Shutdown);
Expand Down

0 comments on commit 44e1b96

Please sign in to comment.