69 Star 68 Fork 967

OpenHarmony / drivers_peripheral

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
README.md 22.08 KB
Copy Edit Raw Blame History
王勃懿 authored 2023-04-24 09:15 . fix:modify dead url

Format

Introduction

This repository mainly defines and implements the Hardware Driver Interfaces (HDIs) of the format module, allowing upper-layer services to perform the following operations for media files:

  • Creating and destroying a muxer and demuxer
  • Starting and stopping a muxer and demuxer
  • Obtaining the attributes of a media file
  • Obtaining the data frame information of a media file
  • Adding data streams and frames to a muxer

Directory Structure

The source code directory structure is as follows:

/drivers/peripheral/format
├── interfaces         # Driver capability APIs provided for upper-layer services
│   └── include       # APIs exposed externally

Available APIs

The format module provides APIs that can be directly called by the framework layer to create or destroy a muxer and demuxer, start or stop a muxer and demuxer, obtain the attributes of a media file, read data frames from a media file, add data streams and frames to a muxer component, and set a callback.

Table 1 describes major HDI APIs provided by the format module.

Table 1 Major HDI APIs of the format module

Header File

API

Description

format_interface.h

void FormatInit(void);

Initializes the format.

void FormatDeInit(void);

Deinitializes the format.

int32_t FormatDemuxerCreate(const FormatSource *source, FormatHandle * const handle);

Creates a demuxer and returns its context handle.

int32_t FormatDemuxerSetParameter(const FormatHandle handle, int32_t trackId, const ParameterItem *metaData, int32_t metaDataCnt);

Sets demuxer attributes.

int32_t FormatDemuxerGetParameter(const FormatHandle handle, int32_t trackId, ParameterItem *metaData);

Obtains demuxer attributes.

int32_t FormatDemuxerSetCallBack(const FormatHandle handle, const FormatCallback *callBack);

Sets a callback for the demuxer.

int32_t FormatDemuxerSetBufferConfig(const FormatHandle handle, const FormatBufferSetting *setting);

(Optional) Sets buffer information for the demuxer.

int32_t FormatDemuxerGetBufferConfig(const FormatHandle handle, FormatBufferSetting *setting);

(Optional) Obtains the buffer information of the demuxer.

int32_t FormatDemuxerPrepare(const FormatHandle handle);

Makes preparations for the demuxer.

int32_t FormatDemuxerGetFileInfo(const FormatHandle handle, FileInfo *info);

Obtains the attributes of a media file.

int32_t FormatDemuxerSelectTrack(const FormatHandle handle, int32_t programId, int32_t trackId);

Selects a specified media track from which the demuxer reads data frames by calling FormatDemuxerReadFrame.)

int32_t FormatDemuxerUnselectTrack(const FormatHandle handle, int32_t programId, int32_t trackId);

Unselects a specified media track from which the demuxer will not read data frames when calling FormatDemuxerReadFrame.

int32_t FormatDemuxerStart(const FormatHandle handle);

Starts the demuxer. After being started, the caller can read data frames from the demuxer.

int32_t FormatDemuxerGetSelectedTrack(const FormatHandle handle, int32_t *programId, int32_t trackId[], int32_t *nums);

Obtains the ID of the media track selected by the demuxer for output.

int32_t FormatDemuxerReadFrame(const FormatHandle handle, FormatFrame *frame, int32_t timeOutMs);

Reads data frames.

int32_t FormatDemuxerFreeFrame(const FormatHandle handle, FormatFrame *frame);

Frees data frames.

int32_t FormatDemuxerSeek(const FormatHandle handle, int32_t streamIndex, int64_t timeStampUs, FormatSeekMode mode);

Seeks for a specified position for the demuxer.

int32_t FormatDemuxerStop(const FormatHandle handle);

Stops the demuxer from working.

int32_t FormatDemuxerDestory(const FormatHandle handle);

Destroys demuxer resources.

int32_t FormatMuxerCreate(FormatHandle * const handle, const FormatOutputConfig *outputConfig);

Creates a muxer and returns its context handle.

int32_t FormatMuxerDestory(const FormatHandle handle);

Destroys a muxer and releases its resources created by calling FormatMuxerCreate.

int32_t FormatMuxerAddTrack(const FormatHandle handle, const TrackSource *trackSource);

Adds a media track source for the muxer.

int32_t FormatMuxerSetCallBack(const FormatHandle handle, const FormatCallback *callBack);

Sets a callback for the muxer.

int32_t FormatMuxerSetOrientation(const FormatHandle handle, int degrees);

Sets the orientation of the video track for the muxer.

int32_t FormatMuxerSetLocation(const FormatHandle handle, int latitude, int longitude);

Sets the geographical information for the output file of the muxer.

int32_t FormatMuxerSetMaxFileSize(const FormatHandle handle, int64_t bytes);

Sets the maximum size (in bytes) for the output file of the muxer.

int32_t FormatMuxerSetMaxFileDuration(const FormatHandle handle, int64_t durationUs);

Sets the maximum duration (in seconds) for the output file.

int32_t FormatMuxerSetFileSplitDuration(const FormatHandle handle, ManualSplitType type, int64_t timestampUs, uint32_t durationUs);

Manually splits a file.

int32_t FormatMuxerStart(const FormatHandle handle);

Starts the muxer.

int32_t FormatMuxerWriteFrame(const FormatHandle handle, const FormatFrame *frameData);

Writes data frames into the muxer.

int32_t FormatMuxerSetNextOutputFile(const FormatHandle handle, int32_t fd);

Sets the descriptor for the next output file.

int32_t FormatMuxerStop(const FormatHandle handle, bool block);

Stops the muxer that was started by calling FormatMuxerStart.

int32_t FormatMuxerSetParameter(const FormatHandle handle, int32_t trackId, const ParameterItem *item, int32_t itemNum);

Sets muxer attributes.

int32_t FormatMuxerGetParameter(const FormatHandle handle, int32_t trackId, ParameterItem *item, int32_t itemNum);

Obtains muxer attributes.

Usage

The core functionalities of this repository are as follows:

  • Provides format HDIs that can be directly called by the framework layer to perform muxer and demuxer-related operations.
  • Provides standard interfaces for device developers to ensure that the OEM vendors comply with the HDI adapter standard. This promises a healthy evolution of the ecosystem.

For details about the invocation and implementation, see the API reference.

Repositories Involved

Driver subsystem

drivers_framework

drivers_adapter

drivers_adapter_khdf_linux

drivers_peripheral

1
https://gitee.com/openharmony/drivers_peripheral.git
git@gitee.com:openharmony/drivers_peripheral.git
openharmony
drivers_peripheral
drivers_peripheral
master

Search