Android multimedia framework OpenCore (PacketVideo) Introduction

sponsored links
Overview of the first part of OpenCore
OpenCore Another common call is PacketVideo, which is Android's multimedia core. In the process of development, PacketVideo is the name of a company, but this multimedia framework OpenCore is the name of the software layer. Android developers in the middle, the two basically the same meaning. Android compared to other libraries, OpenCore the code is very large, it is based on C + + implementation, the definition of the full-function operating system porting layer, a variety of basic functions are packaged into a class form the interface between the various levels more use of inheritance and other means.

OpenCore is a multimedia framework, from a macro point of view, it mainly includes two aspects:

* PVPlayer: providing media player functionality, complete a variety of audio (Audio), video (Video) stream playback (Playback) functionality
* PVAuthor: to provide the function of the media flow records, complete a variety of audio (Audio), video (Video) streams and still image capture

PVPlayer and PVAuthor in the form of SDK available to developers, the SDK can be built on a variety of applications and services. Often used in mobile terminals for multimedia applications such as media players, cameras, video recorders, tape recorders and so on.
In order to better organize the whole architecture, OpenCore the macro level in the software is divided into several levels:

Download (81 KB)

2009-5-13 15:47

* OSCL: Operating System Compatibility Library (operating system compatibility library), the underlying operating system contains a number of operations, in order to better transplant in the different operating systems. Contains the basic data types, configuration, string instruments, IO, error handling, thread, etc., similar to a basic C + + library.
* PVMF: PacketVideo Multimedia Framework (PV multimedia framework) in a file within the framework of analysis (parser) and composition (composer), encoding and decoding of the NODE, you can inherit a common interface, the user layer number of NODE.
* PVPlayer Engine: PVPlayer engine.
* PVAuthor Engine: PVAuthor engine.

In fact, OpenCore content contained so many: from the player's point of view, PVPlayer the input (Source) is a file or network stream, the output (Sink) is the output of audio and video equipment, the basic features include a media stream control document analysis, audio and video stream decoding (Decode) and other aspects. In addition to playing media files from the file, but also includes network-related RTSP streaming (Real Time Stream Protocol, Real Time Streaming Protocol). Terms of flow records in the media, PVAuthor the input (Source) is a camera, microphone and other equipment, the output (Sink) is a variety of documents, including the flow of synchronized audio and video stream encoding (Encode) as well as written documents, etc. function.

OpenCore the SDK in the use of the time, it is possible in the application layer need an adapter (Adaptor), and then implemented on top of the adapter specific function, for PVMF the NODE also be based on a common interface, in the upper implemented to plug-in form.

The second part of the code structure OpenCore

2.1 Code structure

Android open source code as an example, OpenCore code in the following directory: external / opencore /. OpenCore this directory is the root, which contains the subdirectories as follows:

* Android: This is a top inside the library, which is based on PVPlayer and PVAuthor the Android SDK implements a use for the Player and Author.
* Baselibs: contains the data structure and the underlying thread-safe libraries, etc.
* Codecs_v2: This is more of a content library consists mainly of codec implementation, and implementation of an OpenMAX
* Engines: contains PVPlayer and PVAuthor engine implementation
* Extern_libs_v2: contains the header files khronos the OpenMAX
* Fileformats: file format parsing (parser) Tools
* Nodes: to provide some PVMF the NODE, mainly codecs and file's resolve.
* Oscl: operating system compatibility library
* Pvmi: abstract interface to input and output control
* Protocols: mainly network-related RTSP, RTP, HTTP and other protocols related content
* Pvcommon: pvcommon Android.mk document library files, there is no source file.
* Pvplayer: pvplayer Android.mk document library files, there is no source file.
* Pvauthor: pvauthor Android.mk document library files, there is no source file.
* Tools_v2: build tools, and some of the modules can be registered.

In the external / opencore / directory there are two files, as follows:

* Android.mk: a global compilation file
* Pvplayer.conf: configuration file

In the external / opencore / all sub-folder contains a large number of Android.mk files still exist between them "recursive" relationship. For example, the root of Android.mk, to include the following pieces of content:
include $ (PV_TOP) / pvcommon / Android.mk
include $ (PV_TOP) / pvplayer / Android.mk
include $ (PV_TOP) / pvauthor / Android.mk
This indicates the need to refer to pvcommon, pvplayer and pvauthor other Android.mk following file folders.
external / opencore / Android.mk file can follow the various permutations and combinations to use, the contents of several Android.mk merge them in a library.

2.2 Compiler structure
1. Library hierarchy: the Android open-source version of the content compiled, OpenCore all libraries compiled as follows:

* Libopencoreauthor.so: OpenCore the Author Library
* Libopencorecommon.so: OpenCore the bottom of the public library
* Libopencoredownloadreg.so: Download registry
* Libopencoredownload.so: download implementation library
* Libopencoremp4reg.so: MP4 registry
* Libopencoremp4.so: MP4 function realization Library
* Libopencorenet_support.so: Network support library
* Libopencoreplayer.so: OpenCore the Player library
* Libopencorertspreg.so: RTSP registry
* Libopencorertsp.so: RTSP function realization Library

The relationship between the level of library as shown below:

Download (87 KB)

2009-5-13 15:48

OpenCore between the various libraries have the following relationship:
libopencorecommon.so all dependent libraries of libraries, providing a public function;
libopencoreplayer.so and libopencoreauthor.so are two side by side libraries, one for playback and recording, and that the two libraries are OpenCore external interface library;
libopencorenet_support.so provide network support functions;
Some features to plug-in (Plug-In) to use the way into the Player, each function uses two libraries, a realization of specific functions, one for registration.

2. libopencorecommon.so library structure
libopencorecommon.so the core of the whole OpenCore library, compile the control of its path to the file is pvcommon / Android.mk, the file to recursively search subfolders:
include $ (BUILD_SHARED_LIBRARY)
include $ (PV_TOP) / / oscl / oscl / osclbase / Android.mk
include $ (PV_TOP) / / oscl / oscl / osclerror / Android.mk
include $ (PV_TOP) / / oscl / oscl / osclmemory / Android.mk
include $ (PV_TOP) / / oscl / oscl / osclutil / Android.mk
include $ (PV_TOP) / / oscl / pvlogger / Android.mk
include $ (PV_TOP) / / oscl / oscl / osclproc / Android.mk
include $ (PV_TOP) / / oscl / oscl / osclio / Android.mk
include $ (PV_TOP) / / oscl / oscl / osclregcli / Android.mk
include $ (PV_TOP) / / oscl / oscl / osclregserv / Android.mk
include $ (PV_TOP) / / oscl / unit_test / Android.mk
include $ (PV_TOP) / / oscl / oscl / oscllib / Android.mk
include $ (PV_TOP) / / pvmi / pvmf / Android.mk
include $ (PV_TOP) / / baselibs / pv_mime_utils / Android.mk
include $ (PV_TOP) / / nodes / pvfileoutputnode / Android.mk
include $ (PV_TOP) / / baselibs / media_data_structures / Android.mk
include $ (PV_TOP) / / baselibs / threadsafe_callback_ao / Android.mk
include $ (PV_TOP) / / codecs_v2/utilities/colorconvert/Android.mk
include $ (PV_TOP) / / codecs_v2/audio/gsm_amr/amr_nb/common/Android.mk
include $ (PV_TOP) / / codecs_v2/video/avc_h264/common/Android.mk
These files are included Android.mk really need to compile the specified file, the files in the directory and its subdirectories Android.mk. In fact, in libopencorecommon.so library contains the following:

* OSCL all content
* Pvmf framework part of the content (pvmi / pvmf / Android.mk)
* Based on some of the content library (baselibs)
* Some of the content encoding and decoding
* File the output of the node (nodes / pvfileoutputnode / Android.mk)

The structure from the library can be seen, the resulting database structure and the hierarchy of OpenCore not completely overlap. libopencorecommon.so library to contain the contents of the underlying OSCL, PVMF the framework and tools for Node and codec.

3. libopencoreplayer.so library structure

libopencoreplayer.so function library for playback, the control of its path to the file compiled for the pvplayer / Android.mk, it contains the following elements:

include $ (BUILD_SHARED_LIBRARY)
include $ (PV_TOP) / / engines / player / Android.mk
include $ (PV_TOP) / / codecs_v2/audio/aac/dec/util/getactualaacconfig/Android.mk
include $ (PV_TOP) / / codecs_v2/video/avc_h264/dec/Android.mk
include $ (PV_TOP) / / codecs_v2/audio/aac/dec/Android.mk
include $ (PV_TOP) / / codecs_v2/audio/gsm_amr/amr_nb/dec/Android.mk
include $ (PV_TOP) / / codecs_v2/audio/gsm_amr/amr_wb/dec/Android.mk
include $ (PV_TOP) / / codecs_v2/audio/gsm_amr/common/dec/Android.mk
include $ (PV_TOP) / / codecs_v2/audio/mp3/dec/Android.mk
include $ (PV_TOP) / / codecs_v2/utilities/m4v_config_parser/Android.mk
include $ (PV_TOP) / / codecs_v2/utilities/pv_video_config_parser/Android.mk
include $ (PV_TOP) / / codecs_v2/omx/omx_common/Android.mk
include $ (PV_TOP) / / codecs_v2/omx/omx_queue/Android.mk
include $ (PV_TOP) / / codecs_v2/omx/omx_h264/Android.mk
include $ (PV_TOP) / / codecs_v2/omx/omx_aac/Android.mk
include $ (PV_TOP) / / codecs_v2/omx/omx_amr/Android.mk
include $ (PV_TOP) / / codecs_v2/omx/omx_mp3/Android.mk
include $ (PV_TOP) / / codecs_v2/omx/factories/omx_m4v_factory/Android.mk
include $ (PV_TOP) / / codecs_v2/omx/omx_proxy/Android.mk
include $ (PV_TOP) / / nodes / common / Android.mk
include $ (PV_TOP) / / pvmi / content_policy_manager / Android.mk
include $ (PV_TOP) / / pvmi/content_policy_manager/plugins/oma1/passthru/Android.mk
include $ (PV_TOP) / / pvmi / content_policy_manager / plugins / common / Android.mk
include $ (PV_TOP) / / pvmi / media_io / pvmiofileoutput / Android.mk
include $ (PV_TOP) / / fileformats / common / parser / Android.mk
include $ (PV_TOP) / / fileformats/id3parcom/Android.mk
include $ (PV_TOP) / / fileformats / rawgsmamr / parser / Android.mk
include $ (PV_TOP) / / fileformats/mp3/parser/Android.mk
include $ (PV_TOP) / / fileformats/mp4/parser/Android.mk
include $ (PV_TOP) / / fileformats / rawaac / parser / Android.mk
include $ (PV_TOP) / / fileformats / wav / parser / Android.mk
include $ (PV_TOP) / / nodes / pvaacffparsernode / Android.mk
include $ (PV_TOP) / / nodes/pvmp3ffparsernode/Android.mk
include $ (PV_TOP) / / nodes / pvamrffparsernode / Android.mk
include $ (PV_TOP) / / nodes / pvmediaoutputnode / Android.mk
include $ (PV_TOP) / / nodes / pvomxvideodecnode / Android.mk
include $ (PV_TOP) / / nodes / pvomxaudiodecnode / Android.mk
include $ (PV_TOP) / / nodes / pvwavffparsernode / Android.mk
include $ (PV_TOP) / / pvmi / recognizer / Android.mk
include $ (PV_TOP) / / pvmi / recognizer / plugins / pvamrffrecognizer / Android.mk
include $ (PV_TOP) / / pvmi/recognizer/plugins/pvmp3ffrecognizer/Android.mk
include $ (PV_TOP) / / pvmi / recognizer / plugins / pvwavffrecognizer / Android.mk
include $ (PV_TOP) / / engines / common / Android.mk
include $ (PV_TOP) / / engines / adapters / player / framemetadatautility / Android.mk
include $ (PV_TOP) / / protocols / rtp_payload_parser / util / Android.mk
include $ (PV_TOP) / / android / Android.mk
include $ (PV_TOP) / / android/drm/oma1/Android.mk
include $ (PV_TOP) / / tools_v2/build/modules/linux_rtsp/core/Android.mk
include $ (PV_TOP) / / tools_v2/build/modules/linux_rtsp/node_registry/Android.mk
include $ (PV_TOP) / / tools_v2/build/modules/linux_net_support/core/Android.mk
include $ (PV_TOP) / / tools_v2/build/modules/linux_download/core/Android.mk
include $ (PV_TOP) / / tools_v2/build/modules/linux_download/node_registry/Android.mk
include $ (PV_TOP) / / tools_v2/build/modules/linux_mp4/core/Android.mk
include $ (PV_TOP) / / tools_v2/build/modules/linux_mp4/node_registry/Android.mk
libopencoreplayer.so includes the following:

* Some decoding tools
* File parser (mp4)
* Node corresponding decoding tool
* Player of the engine parts (engines / player / Android.mk)
* The player adapter for the Android (android / Android.mk)
* Identification tools (pvmi / recognizer)
* Codec tool OpenMax part (codecs_v2/omx)
* Corresponds to the registration of several plug-in Node

libopencoreplayer.so the contents of the large, mainly for each file parser and decoder, PVPlayer core functionality in engines / player / Android.mk them, and android / Android.mk content is rather special, it is PVPlayer of Android built for the use of a player.
4. libopencoreauthor.so library structure
libopencoreauthor.so is a function of flow records for the media library, control of its path to the file compiled for the pvauthor / Android.mk, it contains the following elements:
include $ (BUILD_SHARED_LIBRARY)
include $ (PV_TOP) / / engines / author / Android.mk
include $ (PV_TOP) / / codecs_v2/video/m4v_h263/enc/Android.mk
include $ (PV_TOP) / / codecs_v2/audio/gsm_amr/amr_nb/enc/Android.mk
include $ (PV_TOP) / / codecs_v2/video/avc_h264/enc/Android.mk
include $ (PV_TOP) / / fileformats/mp4/composer/Android.mk
include $ (PV_TOP) / / nodes / pvamrencnode / Android.mk
include $ (PV_TOP) / / nodes/pvmp4ffcomposernode/Android.mk
include $ (PV_TOP) / / nodes / pvvideoencnode / Android.mk
include $ (PV_TOP) / / nodes / pvavcencnode / Android.mk
include $ (PV_TOP) / / nodes / pvmediainputnode / Android.mk
include $ (PV_TOP) / / android / author / Android.mk

libopencoreauthor.so includes the following:

* Some coding tools (video streaming H263, H264, audio stream Amr)
* Document the composition of the device (mp4)
* Corresponding Node coding tools
* Indicates the media input Node (nodes / pvmediainputnode / Android.m)
* Author of the engine parts (engines / author / Android.mk)
* The author for the Android adapter (android / author / Android.mk)

libopencoreauthor.so main encoder for each file and file composition of devices, PVAuthor core functionality in engines / author / Android.mk them, and android / author / Android.mk is built on a PVAuthor media used for the Android recorder.

5. Several other libraries also Android.mk library file path is as follows:
Network support library libopencorenet_support.so:
tools_v2/build/modules/linux_net_support/core/Android.mk

MP4 function realization Library libopencoremp4.so and registry libopencoremp4reg.so:
tools_v2/build/modules/linux_mp4/core/Android.mk
tools_v2/build/modules/linux_mp4/node_registry/Android.mk

Function realization RTSP library libopencorertsp.so and registry libopencorertspreg.so:
tools_v2/build/modules/linux_rtsp/core/Android.mk
tools_v2/build/modules/linux_rtsp/node_registry/Android.mk

Download and registration databases to achieve library libopencoredownload.so libopencoredownloadreg.so:
tools_v2/build/modules/linux_download/core/Android.mk
tools_v2/build/modules/linux_download/node_registry/Android.mk

Introduction to Part III OpenCore OSCL

OSCL, all known Operating System Compatibility Library (operating system compatibility library), it contains a number of different operating systems in the porting layer functions, the code structure is as follows:
oscl / oscl
| - Config: configuration macro
| - Makefile
| - Makefile.pv
| - Osclbase: includes the basic types, macros, and some similar functions STL containers
| - Osclerror: error handling function
| - Osclio: file IO and Socket functions
| - Oscllib: dynamic library interface functions
| - Osclmemory: memory management, pointers and other functions automatically
| - Osclproc: thread, multi-task communications and other functions
| - Osclregcli: up the function of the client
| - Osclregserv: up server functionality
`- Osclutil: string and other basic functions in oscl directory, each directory represents a general module. OSCL the corresponding function is very detailed, almost every detail of C language features are encapsulated using the C + + to interface to the upper use. In fact, OperCore the PVMF, Engine parts are in use OSCL, the caller of the entire OperCore also need to use OSCL.
In OSCL implementation, many of the typical C-language function is carried out a simple package, for example: osclutil with math-related functions are defined in the oscl_math.inl become embedded (inline) function:
OSCL_COND_EXPORT_REF OSCL_INLINE double oscl_log (double value)
{
return (double) log (value);
}
OSCL_COND_EXPORT_REF OSCL_INLINE double oscl_log10 (double value)
{
return (double) log10 (value);
}
OSCL_COND_EXPORT_REF OSCL_INLINE double oscl_sqrt (double value)
{
return (double) sqrt (value);
}
oscl_math.inl oscl_math.h was again included in the file, so the result is oscl_log () and other functions equivalent to the original use of log () and other functions.

Many C language standard library is defined as the handle C + + classes in the form of realization by some cumbersome, but the complexity is not high. To oscllib example, the code structure is as follows:
oscl / oscl / oscllib /
| - Android.mk
| - Build
| `- Make
| `- Makefile
`- Src
| - Oscl_library_common.h
| - Oscl_library_list.cpp
| - Oscl_library_list.h
| - Oscl_shared_lib_interface.h
| - Oscl_shared_library.cpp
`- Oscl_shared_library.h
oscl_shared_library.h is provided to the upper interface using dynamic library function, which defines the interface as follows:
class OsclSharedLibrary
{
public:
OSCL_IMPORT_REF OsclSharedLibrary ();
OSCL_IMPORT_REF OsclSharedLibrary (const OSCL_String & aPath);
OSCL_IMPORT_REF ~ OsclSharedLibrary ();
OSCL_IMPORT_REF OsclLibStatus LoadLib (const OSCL_String & aPath);
OSCL_IMPORT_REF OsclLibStatus LoadLib ();
OSCL_IMPORT_REF void SetLibPath (const OSCL_String & aPath);
OSCL_IMPORT_REF OsclLibStatus QueryInterface (const OsclUuid & aInterfaceId, OsclAny * & aInterfacePtr);
OSCL_IMPORT_REF OsclLibStatus Close ();
OSCL_IMPORT_REF void AddRef ();
OSCL_IMPORT_REF void RemoveRef ();
}
These interfaces are clearly a relationship with the library loading, and in oscl_shared_library.cpp in its specific function is to use dlopen () and other functions to achieve.

The fourth part of the file format and codec processing section Introduction In multimedia, file format handling and codec (Codec) is based on two aspects. The two aspects of multimedia media player (PlayBack) and the media records (Recording).
During playback in the media, usually media files from the player, the necessary steps to file the two analytical and media stream decoding. For example, an mp4 file, which may include AMR and AAC audio stream, H263, MPEG4 and AVC (H264) video stream, the stream is encapsulated in the package which 3GP, media player will do is from the file Analysis of these flow out, and then the media stream decoding, the decoded data can play.
During the recording of the media, by involving video, audio, image capture function. For the video plus audio recording into a file function, the process and play just the opposite, starting with the hardware devices are video and audio media stream, then its code, code number of the flow at different levels need to be written to the file being eventually be composed of good document.
OpenCore about file formats and codec processing the contents of the Ministry in two parts, each of them in the directory fileformats and codecs_v2. These two parts belong to the basic function, does not involve a specific logic, so they are called by other modules to use, for example: building a variety of Node.

4.1 file format handling

As the same time to play the file and record documents related to two functions, so the file format handling OpenCore There are two types, one is the parser (the parser), the other is the composer (component device).
fileformats directory structure is as follows:
fileformats
| - Avi
| `- Parser
| - Common
| `- Parser
| - Id3parcom
| | - Android.mk
| | - Build
| | - Include
| `- Src
| - Mp3
| `- Parser
| - Mp4
| | - Composer
| `- Parser
| - Rawaac
| `- Parser
| - Rawgsmamr
| `- Parser
`- Wav
`- Parser

Directory contains various subdirectories, which correspond to the different file formats, such as mp3, mp4 and wav and so on.

4.2 Codec

Audio codec for some of the major and Video, codecs_v2 the directory structure is as follows:
codecs_v2
| - Audio
| | - Aac
| | - Gsm_amr
| | - Mp3
| `- Sbc
| - Omx
| | - Factories
| | - Omx_aac
| | - Omx_amr
| | - Omx_common
| | - Omx_h264
| | - Omx_m4v
| | - Omx_mp3
| | - Omx_proxy
| `- Omx_queue
| - Utilities
| | - Colorconvert
| | - M4v_config_parser
| `- Pv_video_config_parser
`- Video
| - Avc_h264
`- M4v_h263
In the audio and video directory corresponds to a subdirectory for various flow, which may contain two directories dec and enc, respectively decoding and encoding. video after the commencement of the contents of the directory is as follows:
`- Video
| - Avc_h264
| | - Common
| | - Dec
| | - Enc
| `- Patent_disclaimer.txt
`- M4v_h263
| - Dec
| - Enc
`- Patent_disclaimer.txt
codecs_v2 subdirectory omx implements a khronos
OpenMAX function. OpenMAX is a framework of standards for multimedia applications by NVIDIA Corporation and Khronos in 2006. OpenMAX IL 1.0 (Integration Layer) specification defines media component interfaces to the embedded devices in the rapid integration of streaming media framework for accelerated codecs.
Design and implementation of OpenMAX can edit the code function with a hardware platform to provide a unified interface and framework can be used directly in the OpenMAX hardware acceleration for encoding and decoding functions as well as output, foreign to maintain a unified interface. But here's OpenMAX is a pure software implementation.

Part V describes OpenCore Player


5.1 Player of the composition
OpenCore's Player of the compiled file is pvplayer / Android.mk, will generate the dynamic library file libopencoreplayer.so. This library contains two aspects: one is the Player of the engine (engine), one component for the Android Player, which is actually an adapter (adapter). engine of the path is engine / player; adapter path is android.

Download (38 KB)

2009-5-13 15:49


5.2 Player Engine Part

OpenCore's Player Engine has a clear interface. In this interface on top of a different system can achieve different depending on your situation Player. Engines in the directory file structure is as follows:
engines / player /
| - Android.mk
| - Build
| | - Linux_nj
| | - Make
| `- Makefile.conf
| - Config
| `- Linux_nj
| - Include
| | - Pv_player_datasink.h
| | - Pv_player_datasinkfilename.h
| | - Pv_player_datasinkpvmfnode.h
| | - Pv_player_datasource.h
| | - Pv_player_datasourcepvmfnode.h
| | - Pv_player_datasourceurl.h
| | - Pv_player_events.h
| | - Pv_player_factory.h
| | - Pv_player_interface.h
| | - Pv_player_license_acquisition_interface.h
| | - Pv_player_registry_interface.h
| | - Pv_player_track_selection_interface.h
| `- Pv_player_types.h
| - Sample_app
| | - Android.mk
| | - Build
| | - Sample_player_app_release.txt
| `- Src
| - Src
| | - Pv_player_datapath.cpp
| | - Pv_player_datapath.h
| | - Pv_player_engine.cpp
| | - Pv_player_engine.h
| | - Pv_player_factory.cpp
| | - Pv_player_node_registry.h
| `- Pv_player_sdkinfo.h
`- Test
| - Android.mk
| - Build
| - Config
`- Src
Which, engines / player / include directory is the interface header file, engines / player / src directory and the private header file source file, the main function of the header file as follows:
pv_player_types.h: define the value of some data structures and enumerations
pv_player_events.h: UUID and a number of error values defined.
pv_player_datasink.h: datasink is the output of media data, the definition of class PVPlayerDataSink, which is the output of media data base, as the interface to use
pv_player_datasinkfilename.h: the definition of class PVPlayerDataSinkFilename inheritance PVPlayerDataSink.
pv_player_datasinkpvmfnode.h: the definition of class PVPlayerDataSinkPVMFNode inheritance PVPlayerDataSink.
pv_player_datasource.h: datasource is the media data input, the definition of class PVPlayerDataSource, which is the base class for the media data input, as the interface.
pv_player_datasourcepvmfnode.h: the definition of class PVPlayerDataSourcePVMFNode inheritance PVPlayerDataSource.
pv_player_datasourceurl.h: the definition of class PVPlayerDataSourceURL inheritance PVPlayerDataSource.
pv_player_interface.h: Definition Player interface PVPlayerInterface, which is an interface class.
pv_player_factory.h: key definitions factory class PVPlayerFactory, used to create and destroy PVPlayerInterface.
In fact, engines / player / src directory, the main implementation class for the pv_player_engine.cpp, which defines the class PVPlayerEngine, PVPlayerEngine inherited PVPlayerInterface, this is an implementation class, in PVPlayerFactory create PVPlayerInterface interface, the actual creation of a PVPlayerEngine .

Download (59 KB)

2009-5-13 15:49

In the Player Engine implementation, including coding and decoding, and flow control functions, while the output of the media set it from the outside lately. PVPlayerInterface basic interfaces defined in accordance with the sequence of operations, the main interface looks like:

  1. PVCommandId AddDataSource (PVPlayerDataSource & aDataSource, const OsclAny * aContextData = NULL); PVCommandId Init (const OsclAny * aContextData = NULL);
  2. PVCommandId AddDataSink (PVPlayerDataSink & aDataSink, const OsclAny * aContextData = NULL);
  3. PVCommandId Prepare (const OsclAny * aContextData = NULL);
  4. PVCommandId Start (const OsclAny * aContextData = NULL);
  5. PVCommandId Pause (const OsclAny * aContextData = NULL);
  6. PVCommandId Resume (const OsclAny * aContextData = NULL);
  7. PVCommandId Stop (const OsclAny * aContextData = NULL);
  8. PVCommandId RemoveDataSink (PVPlayerDataSink & aDataSink, const OsclAny * aContextData = NULL);
  9. PVCommandId Reset (const OsclAny * aContextData = NULL);
  10. PVCommandId RemoveDataSource (PVPlayerDataSource & aDataSource, const OsclAny * aContextData = NULL);


This may include inside DataSink Audio Video output and the output of the two parts. In pv_player_types.h file, define the Player state machine to PVP_STATE_ begin with, as follows:

  1. typedef enum
  2. {
  3. PVP_STATE_IDLE = 1,
  4. PVP_STATE_INITIALIZED = 2,
  5. PVP_STATE_PREPARED = 3,
  6. PVP_STATE_STARTED = 4,
  7. PVP_STATE_PAUSED = 5,
  8. PVP_STATE_ERROR = 6
  9. } PVPlayerState;


PVPlayerInterface the various operations, if successful, could change the Player's state machine: when initialized Player is PVP_STATE_IDLE state, call Init, go to the PVP_STATE_INITIALIZED state; call AddDataSink, enter PVP_STATE_PREPARED state; call Prepare, go to the PVP_STATE_PREPARED state; call start entered PVP_STATE_STARTED state, then you can call the pause into PVP_STATE_PAUSED state.
PVP_STATE_STARTED and PVP_STATE_PAUSED state is the state of play situations, you can start and pause function to switch between the two states.
During playback, the call can be returned PVP_STATE_INITIALIZED stop state, in the call RemoveDataSource return PVP_STATE_IDLE state.

5.3 Android Player Adapter
Android directory defined in the Player of the adapter, this directory contains the files mainly as follows:
android
| - Android.mk
| - Android_audio_mio.cpp
| - Android_audio_mio.h
| - Android_audio_output.cpp
| - Android_audio_output.h
| - Android_audio_output_threadsafe_callbacks.cpp
| - Android_audio_output_threadsafe_callbacks.h
| - Android_audio_stream.cpp
| - Android_audio_stream.h
| - Android_log_appender.h
| - Android_surface_output.cpp
| - Android_surface_output.h
| - Mediascanner.cpp
| - Metadatadriver.cpp
| - Metadatadriver.h
| - Playerdriver.cpp
| - Playerdriver.h
`- Thread_init.cpp
The Android's Player of the "adapter" you need to call the Player Engine OpenCore interface, Android's media player to achieve the required service interface, the ultimate realization of a PVPlayer, and PVPlayer actually inherited MediaPlayerInterface.
In the implementation process, the first to achieve a PlayerDriver, then use PVPlayer, PVPlayer PlayerDriver done by calling a specific function. The realization of the structure as shown:

Download (89 KB)

2009-5-13 15:49

Various operations on the PVPlayerDriver accomplished using a variety of commands, these commands are defined in the playerdriver.h conducted.

  1. enum player_command_type {
  2. PLAYER_QUIT = 1,
  3. PLAYER_SETUP = 2,
  4. PLAYER_SET_DATA_SOURCE = 3,
  5. PLAYER_SET_VIDEO_SURFACE = 4,
  6. PLAYER_SET_AUDIO_SINK = 5,
  7. PLAYER_INIT = 6,
  8. PLAYER_PREPARE = 7,
  9. PLAYER_START = 8,
  10. PLAYER_STOP = 9,
  11. PLAYER_PAUSE = 10,
  12. PLAYER_RESET = 11,
  13. PLAYER_SET_LOOP = 12,
  14. PLAYER_SEEK = 13,
  15. PLAYER_GET_POSITION = 14,
  16. PLAYER_GET_DURATION = 15,
  17. PLAYER_GET_STATUS = 16,
  18. PLAYER_REMOVE_DATA_SOURCE = 17,
  19. PLAYER_CANCEL_ALL_COMMANDS = 18,
  20. };


Implementation of these commands is generally a simple package PVPlayerInterface each interface, for example, to pause for this relatively simple operation, the system implementation process is as follows:

1. The pause function in PVPlayer (in playerdriver.cpp file)

  1. status_t PVPlayer:: pause ()
  2. {
  3. LOGV ("pause");
  4. return mPlayerDriver-> enqueueCommand (new PlayerPause (0,0));
  5. }


Then call its members mPlayerDriver (PlayerDriver type) function, a PlayerPause command in the command sequence, the specific function of the various commands in the playerdriver.h file.

2. PlayerDriver class enqueueCommand will indirectly call to handle for the beginning of each function, for PlayerPause order, call the function is handlePause

  1. void PlayerDriver:: handlePause (PlayerPause * ec)
  2. {
  3. LOGV ("call pause");
  4. mPlayer-> Pause (0);
  5. FinishSyncCommand (ec);
  6. }


Here is a PVPlayerInterface mPlayer pointer type, use this pointer to call the Player Engine OpenCore the PVPlayerEngine class.

In this player adapter implementation, a major work is defined in the framework of the Android media output (including the output of Audio and Video output) into, OpenCore the Player Engine desired form. Here are two important classes are android_surface_output.cpp achieve AndroidSurfaceOutput, android_audio_output.cpp achieve AndroidAudioOutput.
Video output settings for the process defined in the class PlayerDriver 3 members:

  1. PVPlayerDataSink * mVideoSink;
  2. PVMFNodeInterface * mVideoNode;
  3. PvmiMIOControl * mVideoOutputMIO;


Here mVideoSink of type PVPlayerDataSink, which is defined in the Player Engine class interface, mVideoNode of type VMFNodeInterface, in pvmi / pvmf / include the pvmf_node_interface.h defined, this is all PVMF the NODE need a unified interface inheritance , mVideoOutputMIO of type PvmiMIOControl also pvmi / pvmf / include in the definition, which is the output media control interface class diagram.
1. In PVPlayer the setVideoSurface to set up a Video output interface type of the argument used here is ISurface pointers:

  1. status_t PVPlayer:: setVideoSurface (const sp <ISurface> & surface)
  2. {
  3. LOGV ("setVideoSurface (% p)", surface.get ());
  4. mSurface = surface;
  5. return OK;
  6. }


setVideoSurface function sets the PVPlayer a member of the mSurface, really set the Video output interface function run_set_video_surface () function is implemented:

  1. void PVPlayer:: run_set_video_surface (status_t s, void * cookie)
  2. {
  3. LOGV ("run_set_video_surface s =% d", s);
  4. if (s == NO_ERROR) {
  5. PVPlayer * p = (PVPlayer *) cookie;
  6. if (p-> mSurface == NULL) {
  7. run_set_audio_output (s, cookie);
  8. } Else {
  9. p-> mPlayerDriver-> enqueueCommand (new PlayerSetVideoSurface (p-> mSurface, run_set_audio_output, cookie));
  10. }
  11. }
  12. }


Then use the command PlayerSetVideoSurface, will eventually call to PlayerDriver the handleSetVideoSurface function.
2. handleSetVideoSurface function to achieve the following:

  1. void PlayerDriver:: handleSetVideoSurface (PlayerSetVideoSurface * ec)
  2. {
  3. int error = 0;
  4. mVideoOutputMIO = new AndroidSurfaceOutput (ec-> surface ());
  5. mVideoNode = PVMediaOutputNodeFactory:: CreateMediaOutputNode (mVideoOutputMIO);
  6. mVideoSink = new PVPlayerDataSinkPVMFNode;
  7. ((PVPlayerDataSinkPVMFNode *) mVideoSink) -> SetDataSinkNode (mVideoNode);
  8. ((PVPlayerDataSinkPVMFNode *) mVideoSink) -> SetDataSinkFormatType (PVMF_YUV420);
  9. OSCL_TRY (error, mPlayer-> AddDataSink (* mVideoSink, ec));
  10. OSCL_FIRST_CATCH_ANY (error, commandFailed (ec));
  11. }


First established here, a founding member of mVideoOutputMIO (type PvmiMIOControl), then create the class is a class AndroidSurfaceOutput, this class inherits PvmiMIOControl, it can be used as PvmiMIOControl use. Then call PVMediaOutputNodeFactory:: CreateMediaOutputNode established PVMFNodeInterface type mVideoNode. Then create PVPlayerDataSinkPVMFNode type mVideoSink, PVPlayerDataSinkPVMFNode itself inherited PVPlayerDataSink, so you can use as a PVPlayerDataSink. Call SetDataSinkNode function mVideoNode set mVideoSink data output node.

Download (64 KB)

2009-5-13 15:49

In fact, Video output, the basic functions are completed in the class AndroidSurfaceOutput, in this class among the main work is to Android's ISurface Player Engine output as the output. Last call for PVPlayerInterface AddDataSink will mVideoSink increase output.
Achieved in the android_surface_output.cpp file class AndroidSurfaceOutput, this class is equivalent to a OpenCore Player Engine's Android Video output and the output of the "adapter." AndroidSurfaceOutput class itself inherits class PvmiMIOControl, Youyi ISurface its type constructor parameters. Implementation of this class is to use ISurface achieve PvmiMIOControl all interfaces.

Introduction Part VI OpenCore Author


android / author /
| - Android.mk
| - Android_audio_input.cpp
| - Android_audio_input.h
| - Android_audio_input_threadsafe_callbacks.cpp
| - Android_audio_input_threadsafe_callbacks.h
| - Android_camera_input.cpp
| - Android_camera_input.h
| - Authordriver.cpp
| - Authordriver.h
`- Mediarecorder.cpp

engines / author /
| - Android.mk
| - Build
| | - Make
| `- Makefile
| - Include
| | - Pvauthorenginefactory.h
| `- Pvauthorengineinterface.h
| - Src
| | - Pvae_tuneables.h
| | - Pvaenodeutility.cpp
| | - Pvaenodeutility.h
| | - Pvauthorengine.cpp
| | - Pvauthorengine.h
| `- Single_core
`- Test
| - Android.mk
| - Build
| - Config
| - Src
`- Test_input
  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of Android multimedia framework OpenCore (PacketVideo) Introduction

  • JavaScript object model - implementation of model

    http://www.cnblogs.com/RicCC/archive/2008/02/15/JavaScript-Object-Model-Execution-Model.html Cow too, and it is the browser developers. . . . Data Type <br /> The basic data types are basic data types of the JS implementation language of the bottom.

  • Libmemcached the rails to do with cache store client

    libmemcached is a C library based on the memcache client, ruby has a package: http://github.com/fauna/memcached/tree/master Rails 2.3.2 to take advantage of the own client the opportunity to compare performance, but also a measure to do it, compared to it

  • Libmemcached to do with rails of the cache store client

    libmemcached is a C library based on the memcache client, ruby has a package: http://github.com/fauna/memcached/tree/master Take advantage of the client comes with Rails 2.3.2 for performance comparison of the opportunity to make it a measure, compar ...

  • Ruby numerical types and string types

    Next Ruby novice, there is a master problem, please help answer this question: Say Ruby book on basic data types are objects, may be why the numerical type of object_id is the same, two different "5" are the same object, and string type is ...

  • python vs ruby

    Object Language 1.python are weak, and ruby are pure object language python can not object to run, but the ruby is the foundation of Object. And python packages bound for the relatively weak, while the relative strength of ruby. Such as a class example of

  • Ruby On Rails (1) hellowolrd

    1. What is Ruby On Rails Ruby On Rails is a Ruby-based Web development framework. Ruby is an object-oriented scripting programming language. 2.Ruby has the following advantages: Explanation-based implementation, convenient and quick Ruby is the interprete

  • Faster completion of projects

    Distributed platform originally planned to use asynchronous methods to complete the programming and implementation of lightweight threads later modified to be compatible protocol, and later found that the logic of existing projects synchronous code b ...

  • 12 The most important J2EE best practices

    MVC Framework (as well as the J2EE implementation of the MVC) is one of the advantages of the component elements can (in fact, very easy) on your application for unit testing. Therefore, you can easily entity bean, session bean and the JSP an independent

  • JAVA interview questions

    JAVA interview questions 1, object-oriented features of what has 1. Abstract 2. Inheritance 3. Packaging 4. Polymorphisms 2, String data types are the most basic right? Basic data types include byte, int, char, long, float, double, boolean and short. java

  • Great collection of java interview topics

    1, object-oriented features of what has 1. Abstract: Abstract is that it has overlooked a subject has nothing to do with the current goal of those aspects in order to more fully with the current objectives of the attention-related aspects. Abstract does n

blog comments powered by Disqus
Recent
Recent Entries
Tag Cloud
Random Entries