Class: shaka.util.ContentDatabase

Constructor

new ContentDatabase(mode, parent)

Creates a new ContentDatabase, which manages a database for reading and writing streams to and from persistent storage.
Parameters:
Name Type Description
mode string The I/O mode, which must be either 'readonly' or 'readwrite'.
parent shaka.util.FakeEventTarget
Extends:
Source:

Members

(private, static, constant) CONTENT_STORE_ :string

The name of the content store in the IndexedDb instance.
Type:
  • string
Source:

(static, constant) DB_NAME :string

The name of the IndexedDb instance.
Type:
  • string
Source:

(private, static, constant) DB_VERSION_ :number

The current version of the database.
Type:
  • number
Source:

(private, static, constant) GROUP_STORE_ :string

The name of the group store in the IndexedDb instance.
Type:
  • string
Source:

(private, static, constant) INDEX_STORE_ :string

The name of the index store in the IndexedDb instance.
Type:
  • string
Source:

(private) db_ :IDBDatabase

Type:
  • IDBDatabase
Source:

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

Type:
Inherited From:
Source:

(private) mode_ :string

Type:
  • string
Source:

(protected) parent :shaka.util.FakeEventTarget

Type:
Inherited From:
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:

closeDatabaseConnection()

Closes the connection to the database.
Source:

(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.
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.
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.
Source:
Returns:
A reference to the content store.
Type
IDBObjectStore

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

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

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

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

(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.
Source:
Returns:
A reference to a store.
Type
IDBObjectStore

(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:

(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.
Source:
Returns:
Type
Promise

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 }
Source:
Returns:
Type
Promise

Type Definitions

GroupInformation

Type:
  • {group_id: number, stream_ids: !Array.<number>, session_ids: !Array.<string>, duration: ?number, key_system: string, license_server: string, with_credentials: boolean, distinctive_identifier: boolean, audio_robustness: string, video_robustness: string}
Source:

SegmentInformation

Type:
  • {start_time: number, end_time: ?number, start_byte: number, url: string}
Source:

StreamIndex

Type:
Source: