×
Namespaces

Variants
Actions

Symbian^3 HDMI Output

From Nokia Developer Wiki
Jump to: navigation, search

Using HDMI output on Symbian^3 devices

Article Metadata
Tested with
Devices(s): Nokia N8-00
Compatibility
Platform(s): Symbian^3
Device(s): All with HDMI
Platform Security
Signing Required: Self-Signed
Article
Created: jmagic (05 Aug 2011)
Last edited: hamishwillee (01 Nov 2013)

Contents

Overview

Most Symbian^3 phones include HDMI output, capable of outputting an HD 720p signal to an external display. By default, the signal replicates the phone's LCD screen, but in this snippet we explain how to utilise it from the OpenGL ES application. The code is from http://github.com/nokia-developer/epong which supports rendering on an HDMI display.

Preconditions

Symbian^3 SDK 1.0

Related classes

  • CWsScreenDevice
  • CAccMonitor
  • RConnectedAccessories
  • RAccMonCapabilityArray
  • MAccMonitorObserver

Initialisation

HDMI output is accessed as screen device number 1 using the CWsScreenDevice class. When you are creating a new application window, you create it in RWindowGroup attached to this specific device, and later create your RWindow instance for the same window group. The following code obtains screen #1 and creates a full-screen window on it:

               iScreenDevice = new (ELeave) CWsScreenDevice(iWsSession);               
User::LeaveIfError(iScreenDevice->Construct(1)); // display number 1
iWsSession.ComputeMode(RWsSession::EPriorityControlDisabled);
iWindowGroup = new (ELeave) RWindowGroup(iWsSession);
User::LeaveIfError(iWindowGroup->Construct(KWgId, iScreenDevice));
iWindow = new (ELeave) RWindow(iWsSession);
User::LeaveIfError(iWindow->Construct(*iWindowGroup, (TUint32) iWindow));
iWindow->SetExtent(TPoint(0, 0), iScreenDevice->SizeInPixels());
iWindow->SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront + 1);
iWindow->SetNonFading(ETrue);
iWindow->SetVisible(ETrue);
iWindow->Activate();

Later on, passing the same window to the EGL create surface method will allow the rendering of GL ES content:

               // init display and choose config before this line
iEglSurface = eglCreateWindowSurface(iEglDisplay, config, iWindow, NULL);

To dispose of the window, use the standard GLES teardown process and close the handles to window server objects.

Detecting connect and disconnect

The presence of an HDMI cable can be queried by checking for a capability for KAccMonHDMI, using the accessory monitoring API (CAccMonitor).

The monitoring API also allows observing changes in HDMI connectivity if you provide an instance of the MAccMonitorObserver interface.

        // MAccMonitorObserver 
virtual void ConnectedL( CAccMonitorInfo* aAccessoryInfo );
virtual void DisconnectedL( CAccMonitorInfo* aAccessoryInfo );
virtual void AccMonitorObserverError( TInt aError ) ;

The following snippet initialises the monitor API, manually invokes a callback for ALL currently connected accessories, and starts listening for the connection and disconnection of an HDMI cable.

               iAccMonitor = CAccMonitor::NewL();
// invoke callback for all currently connected accessories
RConnectedAccessories array;
CleanupClosePushL(array);
iAccMonitor->GetConnectedAccessoriesL(array);
for (int i = 0; i < array.Count(); i++)
{
ConnectedL(array[i]); // manually call callback method in init
}
CleanupStack::PopAndDestroy(&array);
 
// register to listen for changes
RAccMonCapabilityArray capabilityArray;
CleanupClosePushL(capabilityArray);
capabilityArray.Append(KAccMonHDMI);
iAccMonitor->StartObservingL(this, capabilityArray);
CleanupStack::PopAndDestroy(&capabilityArray);

When an accessory is connected, the ConnectedL method is invoked. The following code checks if the accessory is a connected HDMI cable, and if so, it initialises the new OpenGL ES window for the HDMI screen.

void CHdmiOutput::ConnectedL(CAccMonitorInfo *aAccessoryInfo)
{
if (aAccessoryInfo->Exists(KAccMonHDMI))
{
CreateWindowL();
if (iCallback) iCallback->OutputChanged(this); // your own callback
}
}

Download

For the whole eponggame project, see: http://github.com/nokia-developer/epong

This page was last modified on 1 November 2013, at 09:06.
67 page views in the last 30 days.