ml_media_data_source.h
Types
Name | |
---|---|
typedef int64_t()(MLHandle media_data_source, size_t position, size_t size, uint8_t buffer, void *context) | MLMediaDataSourceReadAt Called to request data from the given position. |
typedef int64_t()(MLHandle media_data_source, void context) | MLMediaDataSourceGetSize Called to get the size of the data source. |
typedef void()(MLHandle media_data_source, void context) | MLMediaDataSourceClose Called before deleting |
Functions
Name | |
---|---|
MLResult | MLMediaDataSourceCreate(MLMediaDataSourceReadAt read_at, MLMediaDataSourceGetSize get_size, MLMediaDataSourceClose close, void context, MLHandle out_handle) Create a new MediaDataSource object. |
MLResult | MLMediaDataSourceDestroy(MLHandle media_data_source) Destroy a #MediaDataSource object. |
Types Documentation
MLMediaDataSourceReadAt
typedef int64_t(* MLMediaDataSourceReadAt) (MLHandle media_data_source, size_t position, size_t size, uint8_t *buffer, void *context);
Called to request data from the given position.
Parameters
media_data_source | MLHandle as returned by MLMediaDataSourceCreate(). | |
position | The position in the data source to read from. | |
size | The number of bytes to read. | |
buffer | The buffer to read the data into. | |
context | User data as passed to MLMediaDataSourceCreate(). |
Implementations should should write up to size
bytes into buffer
, and return the number of bytes written.
Return 0 to indicate that end of stream is reached. Return -1 on error.
Return: The number of bytes read, or -1 if there was an error.
MLMediaDataSourceGetSize
typedef int64_t(* MLMediaDataSourceGetSize) (MLHandle media_data_source, void *context);
Called to get the size of the data source.
Parameters
media_data_source | MLHandle as returned by MLMediaDataSourceCreate(). | |
context | User data as passed to MLMediaDataSourceCreate(). |
Return: the size of data source in bytes, or -1 if the size is unknown.
MLMediaDataSourceClose
typedef void(* MLMediaDataSourceClose) (MLHandle media_data_source, void *context);
Called before deleting |this|. The other methods may return errors if they're called after calling close().
Parameters
media_data_source | MLHandle as returned by MLMediaDataSourceCreate(). | |
context | User data as passed to MLMediaDataSourceCreate(). |
Functions Documentation
MLMediaDataSourceCreate
MLResult MLMediaDataSourceCreate(
MLMediaDataSourceReadAt read_at,
MLMediaDataSourceGetSize get_size,
MLMediaDataSourceClose close,
void * context,
MLHandle * out_handle
)
Create a new MediaDataSource object.
Parameters
MLMediaDataSourceReadAt | read_at | MLMediaDataSourceReadAt callback. |
MLMediaDataSourceGetSize | get_size | MLMediaDataSourceGetSize callback. |
MLMediaDataSourceClose | close | MLMediaDataSourceClose callback. |
void * | context | User data to be passed to callbacks. |
MLHandle * | out_handle | The MLHandle to the new source object created. Only valid if result is MLResult_Ok. |
Returns
MLResult | MLResult_InvalidParam | One of the parameters is invalid. |
MLResult | MLResult_Ok | if operation was successful. |
MLResult | MLResult_UnspecifiedFailure | The operation failed with an unspecified error. |
Required Permissions:
- None
Deprecated since 1.4.0. Scheduled for removal.
MLMediaDataSourceDestroy
MLResult MLMediaDataSourceDestroy(
MLHandle media_data_source
)
Destroy a #MediaDataSource object.
Parameters
MLHandle | media_data_source | MLHandle to the #MediaDataSource object to destroy. |
Returns
MLResult | MLResult_InvalidParam | One of the parameters is invalid. |
MLResult | MLResult_Ok | if operation was successful. |
MLResult | MLResult_UnspecifiedFailure | The operation failed with an unspecified error. |
Required Permissions:
- None
Deprecated since 1.4.0. Scheduled for removal.
Source code
// %BANNER_BEGIN%
// ---------------------------------------------------------------------
// %COPYRIGHT_BEGIN%
// Copyright (c) 2017 Magic Leap, Inc. All Rights Reserved.
// Use of this file is governed by the Software License Agreement,
// located here: https://www.magicleap.com/software-license-agreement-ml2
// Terms and conditions applicable to third-party materials accompanying
// this distribution may also be found in the top-level NOTICE file
// appearing herein.
// %COPYRIGHT_END%
// ---------------------------------------------------------------------
// %BANNER_END%
#pragma once
#include "ml_api.h"
#include "ml_types.h"
ML_EXTERN_C_BEGIN
typedef int64_t (*MLMediaDataSourceReadAt) (MLHandle media_data_source, size_t position, size_t size, uint8_t *buffer, void *context);
typedef int64_t (*MLMediaDataSourceGetSize) (MLHandle media_data_source, void *context);
typedef void (*MLMediaDataSourceClose) (MLHandle media_data_source, void *context);
ML_DEPRECATED_MSG("Use standard Android SDK APIs.")
ML_API MLResult ML_CALL MLMediaDataSourceCreate(MLMediaDataSourceReadAt read_at, MLMediaDataSourceGetSize get_size, MLMediaDataSourceClose close, void *context, MLHandle *out_handle);
ML_DEPRECATED_MSG("Use standard Android SDK APIs.")
ML_API MLResult ML_CALL MLMediaDataSourceDestroy(MLHandle media_data_source);
ML_EXTERN_C_END