ml_media_stream_source.h
Types
Name | |
---|---|
typedef void()(MLHandle media_stream_source, void context) | MLMediaStreamSourceOnBufferAvailable Called when buffers becomes available. |
Functions
Name | |
---|---|
MLResult | MLMediaStreamSourceCreate(MLMediaStreamSourceOnBufferAvailable on_buffer_available, void context, MLHandle out_handle) Create a new MediaStreamSource object. |
MLResult | MLMediaStreamSourceDestroy(MLHandle media_stream_source) Destroy a MediaStreamSource object. |
MLResult | MLMediaStreamSourceGetBuffer(MLHandle media_stream_source, size_t out_id, uint8_t ** out_ptr, size_t out_size) Get a buffer where data can be written. |
MLResult | MLMediaStreamSourcePushBuffer(MLHandle media_stream_source, size_t id, size_t size) Push a buffer. |
MLResult | MLMediaStreamSourcePushEOS(MLHandle media_stream_source) Push End-Of-Stream event. |
Types Documentation
MLMediaStreamSourceOnBufferAvailable
typedef void(* MLMediaStreamSourceOnBufferAvailable) (MLHandle media_stream_source, void *context);
Called when buffers becomes available.
Parameters
media_stream_source | MLHandle as returned by MLMediaStreamSourceCreate(). | |
context | User data as passed to MLMediaStreamSourceCreate(). |
Signal that at least one buffer is now available. Application should then call getBuffer() as much as possible until it returns false, or until no more data is currently available in the application.
Functions Documentation
MLMediaStreamSourceCreate
MLResult MLMediaStreamSourceCreate(
MLMediaStreamSourceOnBufferAvailable on_buffer_available,
void * context,
MLHandle * out_handle
)
Create a new MediaStreamSource object.
Parameters
MLMediaStreamSourceOnBufferAvailable | on_buffer_available | MLMediaStreamSourceOnBufferAvailable 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.
MLMediaStreamSourceDestroy
MLResult MLMediaStreamSourceDestroy(
MLHandle media_stream_source
)
Destroy a MediaStreamSource object.
Parameters
MLHandle | media_stream_source | MLHandle to the MediaStreamSource 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.
MLMediaStreamSourceGetBuffer
MLResult MLMediaStreamSourceGetBuffer(
MLHandle media_stream_source,
size_t * out_id,
uint8_t ** out_ptr,
size_t * out_size
)
Get a buffer where data can be written.
Parameters
MLHandle | media_stream_source | MLHandle as returned by MLMediaStreamSourceCreate(). |
size_t * | out_id | An opaque ID that should be passed to MLMediaStreamSourcePushBuffer(). |
uint8_t ** | out_ptr | The location where to write data. |
size_t * | out_size | Maximum bytes that can be written in out_ptr . |
Returns
MLResult | MLResult_Ok | If operation was successful. |
MLResult | MLResult_InvalidParam | One of the parameters is invalid. |
MLResult | MLResult_UnspecifiedFailure | The operation failed with an unspecified error. |
Required Permissions:
- None
If a buffer is available, true is returned and out_id
, out_ptr
and out_size
are set. Application can then write up to out_size
bytes into out_ptr
and push that data using MLMediaStreamSourcePushBuffer().
If no buffer is available, false is returned and application should wait for MLMediaStreamSourceOnBufferAvailable() to be called before retrying.
Deprecated since 1.4.0. Scheduled for removal.
MLMediaStreamSourcePushBuffer
MLResult MLMediaStreamSourcePushBuffer(
MLHandle media_stream_source,
size_t id,
size_t size
)
Push a buffer.
Parameters
MLHandle | media_stream_source | MLHandle as returned by MLMediaStreamSourceCreate(). |
size_t | id | The ID of the buffer as given by MLMediaStreamSourceGetBuffer(). |
size_t | size | The number of bytes actually written in the buffer. |
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
Queue a buffer acquired from MLMediaStreamSourceGetBuffer() once data has been written.
Deprecated since 1.4.0. Scheduled for removal.
MLMediaStreamSourcePushEOS
MLResult MLMediaStreamSourcePushEOS(
MLHandle media_stream_source
)
Push End-Of-Stream event.
Parameters
MLHandle | media_stream_source | MLHandle as returned by MLMediaStreamSourceCreate(). |
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
Signal that the end of stream is reached and no more data will be pushed.
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 void (*MLMediaStreamSourceOnBufferAvailable) (MLHandle media_stream_source, void *context);
ML_DEPRECATED_MSG("Use standard Android SDK and NDK APIs.")
ML_API MLResult ML_CALL MLMediaStreamSourceCreate(MLMediaStreamSourceOnBufferAvailable on_buffer_available, void *context, MLHandle *out_handle);
ML_DEPRECATED_MSG("Use standard Android SDK and NDK APIs.")
ML_API MLResult ML_CALL MLMediaStreamSourceDestroy(MLHandle media_stream_source);
ML_DEPRECATED_MSG("Use standard Android SDK and NDK APIs.")
ML_API MLResult ML_CALL MLMediaStreamSourceGetBuffer(MLHandle media_stream_source, size_t *out_id, uint8_t **out_ptr, size_t *out_size);
ML_DEPRECATED_MSG("Use standard Android SDK and NDK APIs.")
ML_API MLResult ML_CALL MLMediaStreamSourcePushBuffer(MLHandle media_stream_source, size_t id, size_t size);
ML_DEPRECATED_MSG("Use standard Android SDK and NDK APIs.")
ML_API MLResult ML_CALL MLMediaStreamSourcePushEOS(MLHandle media_stream_source);
ML_EXTERN_C_END