Class: shaka.util.ContentDatabaseWriter

Constructor

new ContentDatabaseWriter(estimator, parent)

Creates a new ContentDatabaseWriter.
Parameters:
Name Type Description
estimator shaka.util.IBandwidthEstimator
parent shaka.util.FakeEventTarget
Extends:
Source:
Fires:

Members

(private, static, constant) TARGET_SEGMENT_SIZE_ :number

The target size of each chunk in bytes of content stored in the database.
Type:
  • number
Source:

(private) estimator_ :shaka.util.IBandwidthEstimator

Type:
Source:

(private, non-null) listeners_ :shaka.util.MultiMap.<shaka.util.FakeEventTarget.ListenerType>

Type:
Inherited From:
Source:

(private) mode_ :string

Type:
  • string
Inherited From:
Source:

(protected) parent :shaka.util.FakeEventTarget

Type:
Inherited From:
Source:

(private) segmentRequestTimeout_ :number

Type:
  • number
Source:

Methods

addEventListener(type, listener, opt_capturingopt)

Add an event listener to this object.
Parameters:
Name Type Attributes Description
type string The event type to listen for.
listener shaka.util.FakeEventTarget.ListenerType The callback or listener object to invoke.
opt_capturing boolean <optional>
True to listen during the capturing phase, false to listen during the bubbling phase. Note that FakeEventTarget does not support the capturing phase from the standard event model.
Inherited From:
Source:

(private) appendSegment_(ref, state, isLast, segmentnon-null) → (non-null) {Promise}

Appends |segment| to |segments| and adds |segments| array to the database if over target segment size or is the last segment.
Parameters:
Name Type Description
ref shaka.media.SegmentReference The SegmentReference describing the current segment.
state shaka.util.ContentDatabaseWriter.InsertStreamState The state of the current stream being inserted.
isLast boolean True for the last segment in a stream.
segment ArrayBuffer The current segment of the stream.
Source:
Returns:
Type
Promise

closeDatabaseConnection()

Closes the connection to the database.
Inherited From:
Source:

(private) concatArrayBuffers_(bufferOne, bufferTwo) → (non-null) {ArrayBuffer}

Concatenates two ArrayBuffer's.
Parameters:
Name Type Description
bufferOne ArrayBuffer The first ArrayBuffer.
bufferTwo ArrayBuffer The second ArrayBuffer.
Source:
Returns:
Type
ArrayBuffer

(private) createStore_(name, options) → (non-null) {IDBObjectStore}

Creates an object store in the database. It will replace any previous object store with the same name in this database.
Parameters:
Name Type Description
name string The unique name of the object store.
options Object The options for this object store including keyPath and autoIncrement, other options will be ignored.
Inherited From:
Source:
Returns:
Type
IDBObjectStore

deleteDatabase() → (non-null) {Promise}

Closes the connection to the database if required and then deletes the database. The database can only be deleted if there are no other connections to the database.
Inherited From:
Source:
Returns:
Type
Promise

deleteGroup(groupId) → (non-null) {Promise}

Deletes a group of streams from the database.
Parameters:
Name Type Description
groupId number The unique id of the group to delete.
Source:
Returns:
Type
Promise

(private) deleteStream_(streamId) → (non-null) {Promise}

Deletes a stream from the database.
Parameters:
Name Type Description
streamId number The unique id of the stream to delete.
Source:
Returns:
Type
Promise

dispatchEvent(eventnon-null) → {boolean}

Dispatch an event from this object.
Parameters:
Name Type Description
event Event The event to be dispatched from this object.
Inherited From:
Source:
Returns:
True if the default action was prevented.
Type
boolean

(protected) getContentStore() → (non-null) {IDBObjectStore}

Opens a reference to the content store.
Inherited From:
Source:
Returns:
A reference to the content store.
Type
IDBObjectStore

(protected) getGroupStore() → (non-null) {IDBObjectStore}

Opens a reference to the group store.
Inherited From:
Source:
Returns:
A reference to the group store.
Type
IDBObjectStore

(protected) getIndexStore() → (non-null) {IDBObjectStore}

Opens a reference to the index store.
Inherited From:
Source:
Returns:
A reference to the index store.
Type
IDBObjectStore

(private) getNextId_(store) → (non-null) {Promise.<number>}

Gets the next id to be used in the given store. If no entries currently exist 0 will be returned.
Parameters:
Name Type Description
store IDBObjectStore | IDBIndex The store or store's index whose next id will be retrieved.
Source:
Returns:
The next id or 0.
Type
Promise.<number>

(private) getStore_(storeName) → (non-null) {IDBObjectStore}

Opens a reference to a store.
Parameters:
Name Type Description
storeName string The name of a store in the database.
Inherited From:
Source:
Returns:
A reference to a store.
Type
IDBObjectStore

insertGroup(streamInfosnon-null, sessionIdsnon-null, durationnullable, drmInfo) → (non-null) {Promise.<number>}

Inserts a group of streams into the database.
Parameters:
Name Type Attributes Description
streamInfos Array.<!shaka.media.StreamInfo> The streams to insert as a group.
sessionIds Array.<string> The IDs of the MediaKeySessions for this group.
duration number <nullable>
The max stream's entire duration in the group.
drmInfo shaka.player.DrmInfo The group's DrmInfo.
Source:
Returns:
The unique id assigned to the group.
Type
Promise.<number>

(private) insertStream_(streamInfonon-null, segmentIndexnon-null, initData, totalReferences, referencesInserted) → (non-null) {Promise.<number>}

Inserts a stream into the database.
Parameters:
Name Type Description
streamInfo shaka.media.StreamInfo
segmentIndex shaka.media.SegmentIndex
initData ArrayBuffer
totalReferences number Number of references in this streams group.
referencesInserted number Number of references already inserted.
Source:
Returns:
The unique id assigned to the stream.
Type
Promise.<number>

(private) insertStreamContent_(segmentIndexnon-null, statenon-null) → (non-null) {Promise.<shaka.util.ContentDatabaseWriter.InsertStreamState>}

Inserts stream content into the stream content store.
Parameters:
Name Type Description
segmentIndex shaka.media.SegmentIndex
state shaka.util.ContentDatabaseWriter.InsertStreamState The stream's state information.
Source:
Returns:
Type
Promise.<shaka.util.ContentDatabaseWriter.InsertStreamState>

(private) insertStreamIndex_(streamInfonon-null, initData, statenon-null) → (non-null) {Promise.<number>}

Inserts a stream index into the stream index store.
Parameters:
Name Type Description
streamInfo shaka.media.StreamInfo
initData ArrayBuffer
state shaka.util.ContentDatabaseWriter.InsertStreamState The stream's state information.
Source:
Returns:
The unique id assigned to the stream.
Type
Promise.<number>

(private) recursiveDispatch_(eventnon-null) → {boolean}

Dispatches an event recursively without changing its original target.
Parameters:
Name Type Description
event Event
Inherited From:
Source:
Returns:
True if the default action was prevented.
Type
boolean

removeEventListener(type, listener, opt_capturingopt)

Remove an event listener from this object.
Parameters:
Name Type Attributes Description
type string The event type for which you wish to remove a listener.
listener shaka.util.FakeEventTarget.ListenerType The callback or listener object to remove.
opt_capturing boolean <optional>
True to remove a listener for the capturing phase, false to remove a listener for the bubbling phase. Note that FakeEventTarget does not support the capturing phase from the standard event model.
Inherited From:
Source:

(private) requestSegment_(reference) → (non-null) {Promise.<!ArrayBuffer>}

Requests the segment specified by |reference|.
Parameters:
Name Type Description
reference shaka.media.SegmentReference
Source:
Returns:
Type
Promise.<!ArrayBuffer>

(protected) retrieveItem(store, id) → (non-null) {Promise}

Retrieves an item from a store in the database.
Parameters:
Name Type Description
store IDBObjectStore | IDBIndex The store to request an item from.
id number | Array The unique id(s) of item in the store.
Inherited From:
Source:
Returns:
Type
Promise

setSegmentRequestTimeout(timeout)

Sets the segment request timeout in seconds.
Parameters:
Name Type Description
timeout number
Source:

setUpDatabase() → (non-null) {Promise}

Opens a connection to the database and sets up the database if required. If a new version number is given the onupgradeneeded event will be fired. Must be run before any operations can be performed on the database. The database will have the structure: Group Store: { group_id: number stream_ids: Array. session_ids: Array. } Index Store: { stream_id: number, mime_type: string, references: [{shaka.util.ContentDatabase.SegmentInformation}] } Content Store: { stream_id: number, segment_id: number, content: ArrayBuffer }
Inherited From:
Source:
Returns:
Type
Promise

Type Definitions

InsertStreamState

Type:
Source:

Events

ProgressEvent

Fired to indicate progess while downloading and storing streams.
Properties:
Name Type Description
type string 'progress'
detail number Percentage of group references already stored.
bubbles boolean True
Source: