AllShare Framework Developers Guide Getting Started v1.0
-
Upload
tomaz-rdvn -
Category
Documents
-
view
222 -
download
0
Transcript of AllShare Framework Developers Guide Getting Started v1.0
7/22/2019 AllShare Framework Developers Guide Getting Started v1.0
http://slidepdf.com/reader/full/allshare-framework-developers-guide-getting-started-v10 1/24
Copyright © Samsung Electronics Co., Ltd. All rights reserved.
AllShare Framework: Developer’s Guide
Getting Started
Version 1.0
7/22/2019 AllShare Framework Developers Guide Getting Started v1.0
http://slidepdf.com/reader/full/allshare-framework-developers-guide-getting-started-v10 2/24
Copyright © Samsung Electronics Co., Ltd. All rights reserved. 2
Revision History
Version Date Description
1.0 2012.12.18 AllShare Framework Developer’s Guide: Getting Started Version 1.0
Terms and Abbreviations
AllShare A convergence experience among smart devices such as TV, phone, tablet, PC, camera, etc.
AllShare Framework A collection of AllShare functions and its interfaces for convergence applicationdevelopement
AllShare Framework
SDKSoftware Development Kit for AllShare Framework
AllShare Framework
Development Tool
Eclipse plugin which facilitates the development with providing IDE and testing
environment
AllShare device A smart device that supports AllShare
AllShare application An application enhanced by convergence functions of AllShare Framework
AllShare SimulatorA vitual AllShare device that lets you develop and test AllShare applications without using a
physical device
AVD Android Virtual Device
ADT Android Development Tool
Eclipse IDE Eclipse Integrated Development Environment
AV Player An AllShare device that renders audio and video content received from a Media Provider
JDK Java Development Kit
Android SDK Android Software Development Kit
URL Uniform Resource Locator
7/22/2019 AllShare Framework Developers Guide Getting Started v1.0
http://slidepdf.com/reader/full/allshare-framework-developers-guide-getting-started-v10 3/24
Copyright © Samsung Electronics Co., Ltd. All rights reserved. 3
Table of Contents
Getting Started ...................................................................................................................................... 1
1. AllShare Framework Development Tool and SDK Installation .................................................. 1
1.1. Setting up the Environment................................................................................................................. 1
1.2. Installing AllShare Framework Development Tool and SDK .......................................... .................. 1
2. Application Development At a Glance ........................................................................................... 1
2.1. Creating a new AllShare project .......................................................... ............................................... 1
2.2. Running an AllShare application ........................................................................... ........................... 17
2.3. Writing an AllShare application ..................................... ........................................................... ......... 1
Copyright ............................................................................................................................................. 24
7/22/2019 AllShare Framework Developers Guide Getting Started v1.0
http://slidepdf.com/reader/full/allshare-framework-developers-guide-getting-started-v10 4/24
Copyright © Samsung Electronics Co., Ltd. All rights reserved. 4
Getting Started
This document describes how to develop and run an AllShare application with AllShare Framework. Topics covered
include: installing the AllShare Framework Development Tool and the AllShare Framework SDK, creating an AllShareapplication with sample code, and running the application with AllShare Simulators. From this document, you can
learn the basic steps of developing AllShare Applications.
7/22/2019 AllShare Framework Developers Guide Getting Started v1.0
http://slidepdf.com/reader/full/allshare-framework-developers-guide-getting-started-v10 5/24
Copyright © Samsung Electronics Co., Ltd. All rights reserved. 5
1. AllShare Framework Development Tool and SDK Installation
To develop an AllShare application, the AllShare Framework Development Tool and the AllShare Framework SDK is
required. The AllShare Framework Development Tool is an Eclipse plugin that enables developers to create AllShareapplications on the Android platform. It provides download and update manager of the AllShare Framework SDK, the
AllShare application wizard, and the AllShare Simulators. The AllShare Framework SDK consists of the AllShare Library,
API documents, sample codes, and AllShare Framework Service Packages for the emulator. For more information
about AllShare Framework Development Tool and AllShare Framework SDK, refer to the document: “ AllShare
Framework Developer ’ s Guide: Testing Guide.”
1.1. Setting up the Environment
Before installing the AllShare Framework Development Tool, you should prepare the Android development
environment within Eclipse IDE. This section provides instructions on how to set up this environment. If you are
already available to develop an Android application with Eclipse IDE, you can skip this section and go to Section 1.2.
Checking the development system
The AllShare Framework Development Tool supports Windows 7, Ubuntu 10.10 or higher with GStreamer
installed and Mac OS X 10.7 or higher with QuickTime Player 10.1 or higher installed as a development system.
Installing the Java Development Kit
Download and install JDK specific for your operating system. The instructions are available on the JDK web site.
Microsoft Windows:
http://docs.oracle.com/javase/7/docs/webnotes/install/index.html#windows
Linux distributions:http://docs.oracle.com/javase/7/docs/webnotes/install/index.html#linux
Mac OS X:
http://docs.oracle.com/javase/7/docs/webnotes/install/index.html#mac
By using these JDKs you are sure to have all libraries necessary for operation of AllShare Framework
Development Tool.
Some OS distributions may contain “headless” distributions, that do not include graphical libraries (an example
is openjdk-6-jre-headless in Ubuntu).
While AllShare Framework Development Tool tries to handle this situation by informing user, it is better to
make sure you are not using one of those.
Installing the Eclipse IDE
Download the Eclipse IDE 3.7 Indigo or later version available on Eclipse Downloads page below.
The "Eclipse Classic" version is recommended.
http://www.eclipse.org/downloads/
- Unzip the downloaded file to a target folder.
- Run Eclipse IDE by launching "eclipse" application located in the main folder.
Installing Android SDK
Follow the instructions on the web site below. The required Android platform version is 4.1 or higher.
https://developer.android.com/sdk/installing.html
7/22/2019 AllShare Framework Developers Guide Getting Started v1.0
http://slidepdf.com/reader/full/allshare-framework-developers-guide-getting-started-v10 6/24
Copyright © Samsung Electronics Co., Ltd. All rights reserved. 6
Installing ADT Plugin for Eclipse
Follow the instructions on the web site below.
https://developer.android.com/sdk/eclipse-adt.html#installing
The required ADT version is 20.0 or higher. And if a later version of ADT requires the update of AllShare
Framework SDK, it will be notified at AllShare Developer’s site.
Setting Web Browser to be used by TV Web Browser simulator
To use TV Web Browser simulator provided by AllShare Framework Development Tool, it is necessary for
Eclipse to use default internal web browser.
This can be done by opening preferences window (Window -> Preferences), opening Web Browser
configuration tab (General -> Web Browser), and selecting “Use internal web browser”.
On Linux machines, the internal browser may not be configured. It is advised to run
sudo apt-get install libwebkitgtk-1.0-0
Installing GStreamer for Linux
Download and install GStreamer using your distribution install manager.
For example, on Ubuntu:
1) Open Terminal (by selecting Applications -> Accessories -> Terminal)
2) Gain root access by typing in “sudo su” and entering root password
3) Install required GStreamer packages by entering command
sudo apt-get install gstreamer0.10-ffmpeg gstreamer0.10-fluendo-mp3 gstreamer0.10-gnonlin
gstreamer0.10-sdl gstreamer0.10-plugins-bad-multiverse gstreamer0.10-plugins-badgstreamer0.10-plugins-ugly totem-plugins-extra gstreamer-dbus-media-service gstreamer-tools
ubuntu-restricted-extras ttf-mscorefonts-installer
4) Agree to any package installation by pressing “Y” if asked.
7/22/2019 AllShare Framework Developers Guide Getting Started v1.0
http://slidepdf.com/reader/full/allshare-framework-developers-guide-getting-started-v10 7/24
Copyright © Samsung Electronics Co., Ltd. All rights reserved. 7
Installing QuickTime Player for Mac OS X
The official QuickTime for Mac OS X can be found on a web site below.
http://www.apple.com/quicktime/download/
7/22/2019 AllShare Framework Developers Guide Getting Started v1.0
http://slidepdf.com/reader/full/allshare-framework-developers-guide-getting-started-v10 8/24
Copyright © Samsung Electronics Co., Ltd. All rights reserved. 8
1.2. Installing AllShare Framework Development Tool and SDK
Assuming that you have installed the Eclipse IDE and the ADT, as described above, this section explains how to
install the AllShare Framework Development Tool and AllShare Framework SDK. You can install the AllShare
Framework Development Tool as a plugin of Eclipse IDE from the install menu of the Eclipse, and install the AllShare
Framework SDK from the update menu of the AllShare Framework Development Tool.
1. Start Eclipse, then select Help > Install New Software.
2. Click Add in the top right corner. In the Add Repository window that appears, enter AllShare Framework
Development Tool for the Name and the following URL for the Location. Then, click OK.
http://developer.samsung.com/allshare/repository/android/latest/tool
7/22/2019 AllShare Framework Developers Guide Getting Started v1.0
http://slidepdf.com/reader/full/allshare-framework-developers-guide-getting-started-v10 9/24
Copyright © Samsung Electronics Co., Ltd. All rights reserved. 9
3. In the Available Software dialog, select the checkbox of AllShare Development Tool and click Next.
4. Review installation details, then click Next.
7/22/2019 AllShare Framework Developers Guide Getting Started v1.0
http://slidepdf.com/reader/full/allshare-framework-developers-guide-getting-started-v10 10/24
Copyright © Samsung Electronics Co., Ltd. All rights reserved. 10
5. Read and accept license agreements, then click Finish.
6. You can see the downloading status and tools from the window.
Note: If you get a security warning about the authenticity or validity of the software during the installation
process as below, click OK.
7/22/2019 AllShare Framework Developers Guide Getting Started v1.0
http://slidepdf.com/reader/full/allshare-framework-developers-guide-getting-started-v10 11/24
Copyright © Samsung Electronics Co., Ltd. All rights reserved. 11
7. When installation completes, click Restart Now to restart Eclipse.
Installation of the AllShare Framework Development Tool will invoke restart of the Eclipse IDE. When restarted,
the Eclipse shows the AllShare Framework SDK Setup dialog. The following instructions help you in configuring
the AllShare Framework SDK.
8. Select a location to store AllShare Framework SDK.
This repository will contain project samples, libraries, and other items necessary in the development process.
7/22/2019 AllShare Framework Developers Guide Getting Started v1.0
http://slidepdf.com/reader/full/allshare-framework-developers-guide-getting-started-v10 12/24
Copyright © Samsung Electronics Co., Ltd. All rights reserved. 12
9. In the AllShare Framework SDK Manager window that appears, check the update lists, then click Install
selected components.
10. After finishing the SDK update, click OK.
The AllShare Framework Development Tool installation is completed.
7/22/2019 AllShare Framework Developers Guide Getting Started v1.0
http://slidepdf.com/reader/full/allshare-framework-developers-guide-getting-started-v10 13/24
Copyright © Samsung Electronics Co., Ltd. All rights reserved. 13
2. Application Development At a Glance
This section describes creating, writing and running an AllShare application that performs device discovery. With
the given sample project code, you can develop your first AllShare application in short time.
2.1. Creating a new AllShare project
1. Strart Eclipse, and select File > New > AllShare Android Project.
7/22/2019 AllShare Framework Developers Guide Getting Started v1.0
http://slidepdf.com/reader/full/allshare-framework-developers-guide-getting-started-v10 14/24
Copyright © Samsung Electronics Co., Ltd. All rights reserved. 14
2. Enter DeviceDiscovery for the Project Name and select Create new project in workspace, then click Next.
3. Select which AllShare Framework version should be used by the project, then click Next.
7/22/2019 AllShare Framework Developers Guide Getting Started v1.0
http://slidepdf.com/reader/full/allshare-framework-developers-guide-getting-started-v10 15/24
Copyright © Samsung Electronics Co., Ltd. All rights reserved. 15
4. Select Android Build Target (version of Android API that will be used by project), then click Next .
In the following picture, Android 4.1.2 is chosen.
Note: The AllShare Framework SDK requires Android platform 4.1 or higher.
7/22/2019 AllShare Framework Developers Guide Getting Started v1.0
http://slidepdf.com/reader/full/allshare-framework-developers-guide-getting-started-v10 16/24
Copyright © Samsung Electronics Co., Ltd. All rights reserved. 16
5. Enter DeviceDiscovery for the Application Name, com.sec.android.allshare.devicediscovery for the Package
Name and Main for the Create Actvity field of dialog. Then, click Finish.
A new AllShare project is visible in the Package Explorer view.
7/22/2019 AllShare Framework Developers Guide Getting Started v1.0
http://slidepdf.com/reader/full/allshare-framework-developers-guide-getting-started-v10 17/24
Copyright © Samsung Electronics Co., Ltd. All rights reserved. 17
2.2. Running an AllShare application
Launching the AV Player Simulator
For simplicity, we search the AV Player Simulator instead of a smart device. This AllShare Simulator is already
installed in the Eclipse IDE during the installation of the AllShare Framework SDK in Section 1.2.
To activate a simulator, follow the instructions below.
6. Open the AllShare Simulator perspective from Window > Open Perspective > Simulator.
7. Click Activate in Simulator Manager view.
7/22/2019 AllShare Framework Developers Guide Getting Started v1.0
http://slidepdf.com/reader/full/allshare-framework-developers-guide-getting-started-v10 18/24
Copyright © Samsung Electronics Co., Ltd. All rights reserved. 18
8. Select AV Player and click OK.
Note: The AllShare application in this document requires the AV Player Simulator.
Then, the AV Player Simulator appears in the Simulator View in Eclipse.
7/22/2019 AllShare Framework Developers Guide Getting Started v1.0
http://slidepdf.com/reader/full/allshare-framework-developers-guide-getting-started-v10 19/24
Copyright © Samsung Electronics Co., Ltd. All rights reserved. 19
Running the AllShare application
To launch the AllShare application, connect your smart phone to the development system, and follow the
instructions below.
Note: Check that the Android version of the phone is 4.1 or higher.
9. Run the AllShare application on the target device.
With project selected in Package Explorer, select Run > Run as > AllShare Application from top bar menu.
The application is built, installed, and launched automatically on the connected smart phone.
7/22/2019 AllShare Framework Developers Guide Getting Started v1.0
http://slidepdf.com/reader/full/allshare-framework-developers-guide-getting-started-v10 20/24
Copyright © Samsung Electronics Co., Ltd. All rights reserved. 20
2.3. Writing an AllShare application
Now, you can write and modify the skeleton code of the AllShare application, so as to discover other
AllShare devices in the local network. Follow the instructions below.
Get Android permissions
Before using AllShare Framework APIs, “Uses Permission” should be added to “AndroidManifest.xml”. You
should add the following permission in “AndroidManifest.xml”.
1) If you want APIs of media package, you should add the following permission.
AndroidManifest.xml
……
</ application>
< uses-permission android:name="com.sec.android.permission.PERSONAL_MEDIA" />
</ manifest >
If the project is created as an AllShare Project, “com.sec.android.permission.PERSONAL_MEDIA” permission is
already included.
2) If you want APIs of control package, you should add the following permission.
AndroidManifest.xml
……
</ application>
< uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
</ manifest >
3) If you want APIs of screen package, you should add the following permission.AndroidManifest.xml
……
</ application>
< uses-permission android:name="com.android.setting.permission.ALLSHARE_CAST_SERVICE" />
</ manifest >
If the project is created as an AllShare Project, “com.android.setting.permission.ALLSHARE_CAST_SERVICE”
permission is already included.
Modify the XML layout
To launch the AllShare application, the following code should be added in “res/layout/main.xml” as below.main.xml
<?xml version="1.0" encoding="utf-8" ?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/txtLog"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="==AllShare Device Discovery==" />
</LinearLayout>
And save the “res/layout/main.xml” file.
7/22/2019 AllShare Framework Developers Guide Getting Started v1.0
http://slidepdf.com/reader/full/allshare-framework-developers-guide-getting-started-v10 21/24
Copyright © Samsung Electronics Co., Ltd. All rights reserved. 21
Connect to the AllShare Framework Service
Because the AllShare Framework is running as a service, AllShare applications should connect to this service
before using AllShare Framework APIs. When connected, a ServiceProvider instance is created. With this
instance an AllShare application can discover and control other AllShare devices in the local network. To thisend, add the following code in “Main.java” as below
Main.java
public class Main extends Activity {
/** Called when the activity is first created. */
ServiceProvider mServiceProvider = null;
TextView mText = null;
Handler mHandler = new Handler();
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mText = (TextView) findViewById(R.id.txtLog);
mText.append("\n\n" + "Creating service provider!" + "\r\n\n");
ERROR err = ServiceConnector.createServiceProvider (this, new ServiceConnector.IServiceConnectEventListener()
{
@Override
public void onCreated(ServiceProvider sprovider, ServiceState state)
{
mServiceProvider = sprovider;
showDeviceList();
}
@Override
public void onDeleted(ServiceProvider sprovider)
{
mServiceProvider = null;
}
});
if (err == ERROR.FRAMEWORK_NOT_INSTALLED )
{
// AllShare Framework Service is not installed.
}
else if (err == ERROR.INVALID_ARGUMENT ){
// Input argument is invalid. Check and try again
}
else
{
// Success on calling the function.
}
}
If createServiceProvider() succeeds IServiceConnectEventListener, onCreated() will be called with a
ServiceProvider instance.
Discover network devices
7/22/2019 AllShare Framework Developers Guide Getting Started v1.0
http://slidepdf.com/reader/full/allshare-framework-developers-guide-getting-started-v10 22/24
Copyright © Samsung Electronics Co., Ltd. All rights reserved. 22
To discover AllShare devices in the local network, the application should get a DeviceFinder instance by calling
getDeviceFinder(). In the AllShare Framework, an AllShare device in the local network is represented as an
instance of Device class, and there are several device types which have different functionalities: Media Provider,
AV Player, Image Viewer, and TV Browser.
Main.java
private void showDeviceList()
{
if (mServiceProvider == null)
return;
DeviceFinder mDeviceFinder = mServiceProvider.getDeviceFinder();
mDeviceFinder.setDeviceFinderEventListener(DeviceType.DEVICE_AVPLAYER, mDeviceDiscoveryListener);
ArrayList<Device> mDeviceList = mDeviceFinder.getDevices(DeviceDomain.LOCAL_NETWORK ,
DeviceType.DEVICE_AVPLAYER);
if (mDeviceList != null) {
for (int i = 0; i < mDeviceList.size(); i++) {mText.append("AVPlayer: " + mDeviceList.get(i).getName() + " [" + mDeviceList.get(i).getIPAdress() + "] is
found" + "\r\n");
}
}
}
Your application discovers the AV Player Simulator as below.
In order to get events such as join and leave of AllShare devices, the application should register
setDeviceFinderEventListener with a device type of interest and a listener instance. The listener instance canbe made by implementing the interface as below.
Main.java
private final DeviceFinder.IDeviceFinderEventListener mDeviceDiscoveryListener = new
7/22/2019 AllShare Framework Developers Guide Getting Started v1.0
http://slidepdf.com/reader/full/allshare-framework-developers-guide-getting-started-v10 23/24
Copyright © Samsung Electronics Co., Ltd. All rights reserved. 23
DeviceFinder.IDeviceFinderEventListener()
{
@Override
public void onDeviceRemoved(DeviceType deviceType, Device device, ERROR err)
{
mText.append("AVPlayer: " + device.getName() + " [" + device.getIPAdress() + "] is removed" + "\r\n");
}
@Override
public void onDeviceAdded(DeviceType deviceType, Device device, ERROR err)
{
mText.append("AVPlayer: " + device.getName() + " [" + device.getIPAdress() + "] is found" + "\r\n");
}
};
Disconnect from the AllShare Framework Service
Main.java
@Override
protected void onDestroy()
{
if (mServiceProvider != null)
ServiceConnector.deleteServiceProvider (mServiceProvider);
super.onDestroy();
}
7/22/2019 AllShare Framework Developers Guide Getting Started v1.0
http://slidepdf.com/reader/full/allshare-framework-developers-guide-getting-started-v10 24/24
Copyright
Copyright © 2012 Samsung Electronics Co. Ltd. All Rights Reserved.Though every care has been taken to ensure the accuracy of this document, Samsung Electronics Co. Ltd.
cannot accept responsibility for any errors or omissions or for any loss occurred to any person, whether legal
or natural, from acting, or refraining from action, as a result of the information contained herein. Information
in this document is subject to change at any time without obligation to notify any person of such changes.
Samsung Electronics Co. Ltd. may have patents or patent pending applications, trademarks copyrights or
other intellectual property rights covering subject matter in this document. The furnishing of this document
does not give the recipient or reader any license to these patents, trademarks copyrights or other intellectual
property rights.
No part of this document may be communicated, distributed, reproduced or transmitted in any form or byany means, electronic or mechanical or otherwise, for any purpose, without the prior written permission of
Samsung Electronics Co. Ltd.
The document is subject to revision without further notice.
All brand names and product names mentioned in this document are trademarks or registered trademarks of
their respective owners.
For more information, please visit http://developer.samsung.com/