Adobe® AIR® for TV provides several examples of native extensions. The native implementation is written in C++ and uses the AIR for TV extensions development kit (EDK). The EDK is distributed to device manufacturers and system-on-a-chip manufacturers who include AIR for TV with their product. More information about the AIR for TV EDK and creating AIR for TV extensions is in Building an AIR for TV native extension.
As an AIR for TV extension developer, you can:
-
Copy these examples as starting point for your extension.
-
See these examples for code samples that show how to use various C API extension functions as well as the ActionScript ExtensionContext class.
-
Copy the makefile of one of these examples as a starting point for creating the makefile for your extension.
The HelloWorld example is in the following directory of the AIR for TV distribution:
<AIR for TV installation directory>/products/stagecraft/source/ae/edk/helloworld
The HelloWorld example is a simple extension to illustrate basic extension behavior. It does the following:
-
Uses the
ExtensionContext.call()
method to pass a string from the ActionScript side to the native implementation. -
Returns a string from the native implementation to the ActionScript side.
-
Starts a thread in the native implementation that sends asynchronous events to the ActionScript side.
The following table describes each file and its location relative to the
helloworld/
directory:
File |
Description |
---|---|
HelloWorld.as in directory as/device/src/tv/adobe/extension/example/ |
ActionScript side of the real (not the stub) extension that defines the HelloWorld class. It does the following:
|
HelloWorld.as in directory as/distributable/src/tv/adobe/extension/example/ |
ActionScript of the stub extension that defines the HelloWorld class. This ActionScript-only stub defines the extension's ActionScript APIs: Hello() and StartCount(). However, the stub implementations do not call native functions. |
HelloWorldExtensionClient.as in directory client/src |
AIR application that uses the extension. The AIR application is the client of the extension. It does the following:
|
HelloWorldExtensionClient-app.xml in directory client/src |
AIR application descriptor file. Includes the <extensions> element with the extensionID value tv.adobe.extension.example.HelloWorld. |
HelloWorld.h in directory native/ |
The C++ header file of the HelloWorld class. |
HelloWorld.cpp in directory native/ |
The C++ implementation file of the HelloWorld class. The implementation does the following:
|
HelloWorldExtension.cpp in directory native/ |
Contains implementations of the following C API extension functions:
|
PlatformEDKExtension_HelloWorld.mk |
The makefile for the HelloWorld extension. |
ExtensionUtil.h in directory <AIR for TV installation directory> /products/stagecraft/source/ae/edk |
Contains macros convenient to coding your C or C++ implementation. |
ExtensionBridge.cpp in directory <AIR for TV installation directory> /products/stagecraft/source/ae/edk |
The AIR for TV extension module implementation. When you build your native implementation, include this source file in your build. |
phonyEdkAneCert.p12 in directory <AIR for TV installation directory> /products/stagecraft/source/ae/edk |
A phony certificate that the make utility uses for packaging the HelloWorld extension into an ANE file. |
extension.mk in directory <AIR for TV installation directory> /products/stagecraft/source/ae/edk |
The makefile for the extension module. Do not modify this file. |
The Process example is in the following directory of the AIR for TV distribution:
<AIR for TV installation directory>/products/stagecraft/source/ae/edk/process
The Process extension allows an AIR application to manipulate Linux processes, including the following functionality:
-
Spawning a Linux process. The process executes a Linux command that the AIR application specifies.
-
Getting the process identifier of the process.
-
Checking whether the process has completed.
-
Receiving an event that the process has completed.
-
Getting the return code from the completed process.
-
Receiving events indicating that the process has written to
stdout
orstderr
. -
Retrieving the output strings from
stdout
andstderr
. -
Writing strings to
stdin
. -
Sending an interrupt signal to the process.
-
Killing the process.
The following table describes each file and its location relative to the
process/
directory:
File |
Description |
---|---|
Process.as in directory as/device/src/tv/adobe/extension/process/example/ |
ActionScript side of the real (not the stub) extension that defines the Process class. It does the following:
|
ProcessEvent.as in directory as/device/src/tv/adobe/extension/process/example/ |
Defines the ProcessEvent class, which derives from the Event class. The AIR application ActionScript listens for these ProcessEvent notifications. |
Process.as in directory as/distributable/src/tv/adobe/extension/process/example/ |
ActionScript of the stub extension that defines the Process class. This ActionScript-only stub defines the extension's ActionScript APIs. However, the stub implementations do not call native functions. |
ProcessExtensionClient.as in directory client/simple/src |
AIR application that uses the extension. The AIR application is the client of the extension. It provides an example of how an AIR application uses the Process extension APIs. |
ProcessExtensionClient-app.xml in directory client/simple/src |
AIR application descriptor file. Includes the <extensions> element with the extensionID value tv.adobe.extension.process.Process. |
Process.h in directory native/ |
The C++ header file of the abstract Process class. |
ProcessLinux.h in directory native/ |
The C++ header file of the concrete ProcessLinux class. The ProcessLinux class derives from the Process class. It declares private methods and data for a Linux implementation of the Process class. |
ProcessLinux.cpp in directory native/ |
The C++ implementation file of the ProcessLinux class. The implementation includes the following functionality:
|
ProcessExtension.cpp in directory native/ |
Contains implementations of the following C API extension functions:
|
PlatformEDKExtension_Process.mk |
The makefile for the Process extension. |
ExtensionUtil.h in directory <AIR for TV installation directory> /products/stagecraft/source/ae/edk |
Contains macros convenient to coding your C or C++ implementation. |
ExtensionBridge.cpp in directory <AIR for TV installation directory> /products/stagecraft/source/ae/edk |
The AIR for TV extension module implementation. When you build your native implementation, include this source file in your build. |
phonyEdkAneCert in directory <AIR for TV installation directory> /products/stagecraft/source/ae/edk |
A phony certificate that the make utility uses for packaging the Process extension into an ANE file. |
extension.mk in directory <AIR for TV installation directory> /products/stagecraft/source/ae/edk |
The makefile for the extension module. Do not modify this file. |
To build the Hello World or Process extension example on the x86Desktop platform, first build your AIR for TV distribution for the x86Desktop platform. Instructions are in Getting Started with Adobe AIR for TV (PDF) in Quick Start on Linux.
Note: Make sure that you installed the AIR 3 SDK, the The Open Source Flex® SDK, and the Java™ runtime, and included the bin directories in your PATH environment variable. Building native extensions for AIR for TV depends on these libraries.
Next, add building the Hello World or Process extension example to your x86Desktop build. Do the following:
-
Change to the directory:
<AIR for TV installation directory>/products/stagecraft/build/linux/platforms/x86Desktop
-
Link to the .mk file of the extension you want to build. For example:
ln -s <AIR for TV installation directory>/products/stagecraft/source/ae/edk/helloworld/PlatformEDKExtension_HelloWorld.mk
-
Change to the directory:
<AIR for TV installation directory>/products/stagecraft/build/linux
-
Build the distribution, including the extension example:
make
Alternatively, build only the extension example. For example:
make PlatformEDKExtension_HelloWorld.mk
The make utility creates two files for each extension example. It puts the files
in one of the following directories depending on whether you specified debug or
release for SC_BUILD_MODE
:
<AIR for TV installation directory>/build/stagecraft/linux/x86Desktop/debug/bin
<AIR for TV installation directory>/build/stagecraft/linux/x86Desktop/release/bin
The files that the make utility creates for the example extension are:
-
A ZIP file that contains the device-bundled extension.
-
An ANE file that contains the stub or simulator extension.