Skip to content

Commit

Permalink
Merge pull request Azure#104 from WindowsAzure/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Albert Cheng committed Jan 22, 2013
2 parents 2cebbbd + c3cfb9f commit 6760316
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ public void canGetParentBackFromAsset() throws ServiceException, InterruptedExce

String jobName = testJobPrefix + "createJobSuccess";
CreateBatchOperation taskCreator = Task
.create("nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5",
.create(MEDIA_ENCODER_MEDIA_PROCESSOR_2_2_0_0_ID,
"<taskBody>" + "<inputAsset>JobInputAsset(0)</inputAsset>"
+ "<outputAsset>JobOutputAsset(0)</outputAsset>" + "</taskBody>")
.setConfiguration("H.264 256k DSL CBR").setName("My encoding Task");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public abstract class IntegrationTestBase {
protected static final String validButNonexistAccessPolicyId = "nb:pid:UUID:38dcb3a0-ef64-4ad0-bbb5-67a14c6df2f7";
protected static final String validButNonexistLocatorId = "nb:lid:UUID:92a70402-fca9-4aa3-80d7-d4de3792a27a";

protected static final String MEDIA_ENCODER_MEDIA_PROCESSOR_2_2_0_0_ID = "nb:mpid:UUID:70bdc2c3-ebf4-42a9-8542-5afc1e55d217";

protected static final String invalidId = "notAValidId";

@Rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private JobInfo createJob(String name) throws ServiceException {

private CreateBatchOperation getTaskCreator(int outputAssetPosition) {
return Task
.create("nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5",
.create(MEDIA_ENCODER_MEDIA_PROCESSOR_2_2_0_0_ID,
"<taskBody>" + "<inputAsset>JobInputAsset(0)</inputAsset>" + "<outputAsset>JobOutputAsset("
+ outputAssetPosition + ")</outputAsset>" + "</taskBody>")
.setConfiguration("H.264 256k DSL CBR").setName("My encoding Task");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public class TaskIntegrationTest extends IntegrationTestBase {
private static AssetInfo assetInfo;
private Creator jobCreator;

private static final String commonMediaProcessorId = "nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5";
private static final String commonConfiguration = "H.264 256k DSL CBR";

@BeforeClass
Expand All @@ -66,7 +65,7 @@ public void createTaskSuccess() throws ServiceException, UnsupportedEncodingExce
// Arrange

// Required
String mediaProcessorId = commonMediaProcessorId;
String mediaProcessorId = MEDIA_ENCODER_MEDIA_PROCESSOR_2_2_0_0_ID;
String taskBody = constructTaskBody(0);

// Optional parameters
Expand Down Expand Up @@ -102,7 +101,7 @@ public void createTwoTasksSuccess() throws ServiceException {
// Arrange

// Required
String mediaProcessorId = commonMediaProcessorId;
String mediaProcessorId = MEDIA_ENCODER_MEDIA_PROCESSOR_2_2_0_0_ID;
String[] taskBodies = new String[] { constructTaskBody(0), constructTaskBody(1) };

// Optional parameters
Expand Down Expand Up @@ -136,7 +135,7 @@ public void createTwoTasksSuccess() throws ServiceException {
@Test
public void canListTasksWithOptions() throws ServiceException {
// Arrange
String mediaProcessorId = commonMediaProcessorId;
String mediaProcessorId = MEDIA_ENCODER_MEDIA_PROCESSOR_2_2_0_0_ID;
String configuration = commonConfiguration;
String[] taskNameSuffixes = new String[] { "A", "B", "C", "D" };
String baseName = "My encoding Task " + UUID.randomUUID().toString();
Expand All @@ -163,7 +162,7 @@ public void canListTasksWithOptions() throws ServiceException {
@Test
public void cancelTaskSuccess() throws ServiceException, InterruptedException {
// Arrange
String mediaProcessorId = commonMediaProcessorId;
String mediaProcessorId = MEDIA_ENCODER_MEDIA_PROCESSOR_2_2_0_0_ID;
String taskBody = constructTaskBody(0);
String configuration = commonConfiguration;
String name = "My encoding Task " + UUID.randomUUID().toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ private void waitForJobToFinish(JobInfo job) throws InterruptedException, Servic
private List<Task.CreateBatchOperation> createTasks() throws ServiceException {
List<Task.CreateBatchOperation> tasks = new ArrayList<Task.CreateBatchOperation>();

tasks.add(wrapper.createTaskOptions("MP4 to SS", 0, 0, EncoderType.Mp4ToSmoothStream));
tasks.add(wrapper.createTaskOptions("SS to HLS", 0, 1, EncoderType.SmoothStreamsToHls));
tasks.add(wrapper.createTaskOptions("Decryptor", 0, 0, EncoderType.StorageDecryption));
tasks.add(wrapper.createTaskOptions("Processor", 0, 1, EncoderType.WindowsAzureMediaEncoder));
return tasks;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,50 +77,9 @@ class MediaServiceWrapper {

private final String MEDIA_PROCESSOR_STORAGE_DECRYPTION = "Storage Decryption";
private final String MEDIA_PROCESSOR_WINDOWS_AZURE_MEDIA_ENCODER = "Windows Azure Media Encoder";
private final String MEDIA_PROCESSOR_MP4_TO_SMOOTH_STREAMS = "MP4 to Smooth Streams Task";
private final String MEDIA_PROCESSOR_SMOOTH_STREAMS_TO_HLS = "Smooth Streams to HLS Task";

// From http://msdn.microsoft.com/en-us/library/windowsazure/hh973635.aspx
private final String configMp4ToSmoothStreams = "<taskDefinition xmlns='http://schemas.microsoft.com/iis/media/v4/TM/TaskDefinition#'>"
+ " <name>MP4 to Smooth Streams</name>"
+ " <id>5e1e1a1c-bba6-11df-8991-0019d1916af0</id>"
+ " <description xml:lang='en'>Converts MP4 files encoded with H.264 (AVC) video and AAC-LC audio codecs to Smooth Streams.</description>"
+ " <inputFolder />"
+ " <properties namespace='http://schemas.microsoft.com/iis/media/V4/TM/MP4ToSmooth#' prefix='mp4'>"
+ " <property name='keepSourceNames' required='false' value='true' helpText='This property tells the MP4 to Smooth task to keep the original file name rather than add the bitrate bitrate information.' />"
+ " </properties>"
+ " <taskCode>"
+ " <type>Microsoft.Web.Media.TransformManager.MP4toSmooth.MP4toSmooth_Task, Microsoft.Web.Media.TransformManager.MP4toSmooth, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35</type>"
+ " </taskCode>" + "</taskDefinition>";

// From http://msdn.microsoft.com/en-us/library/windowsazure/hh973636.aspx
private final String configSmoothStreamsToAppleHttpLiveStreams = "<taskDefinition xmlns='http://schemas.microsoft.com/iis/media/v4/TM/TaskDefinition#'>"
+ " <name>Smooth Streams to Apple HTTP Live Streams</name>"
+ " <id>A72D7A5D-3022-45f2-89B4-1DDC5457C111</id>"
+ " <description xml:lang='en'>Converts on-demand Smooth Streams encoded with H.264 (AVC) video and AAC-LC audio codecs to Apple HTTP Live Streams (MPEG-2 TS) and creates an Apple HTTP Live Streaming playlist (.m3u8) file for the converted presentation.</description>"
+ " <inputDirectory></inputDirectory>"
+ " <outputFolder>TS_Out</outputFolder>"
+ " <properties namespace='http://schemas.microsoft.com/iis/media/AppleHTTP#' prefix='hls'>"
+ " <property name='maxbitrate' required='true' value='8500000' helpText='The maximum bit rate, in bits per second (bps), to be converted to MPEG-2 TS. On-demand Smooth Streams at or below this value are converted to MPEG-2 TS segments. Smooth Streams above this value are not converted. Most Apple devices can play media encoded at bit rates up to 8,500 Kbps.'/>"
+ " <property name='manifest' required='false' value='' helpText='The file name to use for the converted Apple HTTP Live Streaming playlist file (a file with an .m3u8 file name extension). If no value is specified, the following default value is used: &lt;ISM_file_name&gt;-m3u8-aapl.m3u8'/>"
+ " <property name='segment' required='false' value='10' helpText='The duration of each MPEG-2 TS segment, in seconds. 10 seconds is the Apple-recommended setting for most Apple mobile digital devices.'/>"
+ " <property name='log' required='false' value='' helpText='The file name to use for a log file (with a .log file name extension) that records the conversion activity. If you specify a log file name, the file is stored in the task output folder.' /> "
+ " <property name='encrypt' required='false' value='false' helpText='Enables encryption of MPEG-2 TS segments by using the Advanced Encryption Standard (AES) with a 128-bit key (AES-128).' />"
+ " <property name='pid' required='false' value='' helpText='The program ID of the MPEG-2 TS presentation. Different encodings of MPEG-2 TS streams in the same presentation use the same program ID so that clients can easily switch between bit rates.' />"
+ " <property name='codecs' required='false' value='false' helpText='Enables codec format identifiers, as defined by RFC 4281, to be included in the Apple HTTP Live Streaming playlist (.m3u8) file.' />"
+ " <property name='backwardcompatible' required='false' value='false' helpText='Enables playback of the MPEG-2 TS presentation on devices that use the Apple iOS 3.0 mobile operating system.' />"
+ " <property name='allowcaching' required='false' value='true' helpText='Enables the MPEG-2 TS segments to be cached on Apple devices for later playback.' />"
+ " <property name='passphrase' required='false' value='' helpText='A passphrase that is used to generate the content key identifier.' />"
+ " <property name='key' required='false' value='' helpText='The hexadecimal representation of the 16-octet content key value that is used for encryption.' />"
+ " <property name='keyuri' required='false' value='' helpText='An alternate URI to be used by clients for downloading the key file. If no value is specified, it is assumed that the Live Smooth Streaming publishing point provides the key file.' />"
+ " <property name='overwrite' required='false' value='true' helpText='Enables existing files in the output folder to be overwritten if converted output files have identical file names.' />"
+ " </properties>"
+ " <taskCode>"
+ " <type>Microsoft.Web.Media.TransformManager.SmoothToHLS.SmoothToHLSTask, Microsoft.Web.Media.TransformManager.SmoothToHLS, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35</type>"
+ " </taskCode>" + "</taskDefinition>";

public static enum EncoderType {
WindowsAzureMediaEncoder, Mp4ToSmoothStream, SmoothStreamsToHls, StorageDecryption
WindowsAzureMediaEncoder, StorageDecryption
}

public MediaServiceWrapper(MediaContract service) {
Expand Down Expand Up @@ -312,16 +271,8 @@ public Task.CreateBatchOperation createTaskOptions(String taskName, int inputAss
String processor = null;
String configuration = null;
switch (encoderType) {
case Mp4ToSmoothStream:
processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_MP4_TO_SMOOTH_STREAMS, "2.1.0.0");
configuration = configMp4ToSmoothStreams;
break;
case SmoothStreamsToHls:
processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_SMOOTH_STREAMS_TO_HLS, "2.1.0.0");
configuration = configSmoothStreamsToAppleHttpLiveStreams;
break;
case WindowsAzureMediaEncoder:
processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_WINDOWS_AZURE_MEDIA_ENCODER, "2.1.1.0");
processor = getMediaProcessorIdByName(MEDIA_PROCESSOR_WINDOWS_AZURE_MEDIA_ENCODER, "2.2.0.0");
// Full list of configurations strings for version 2.1 is at:
// http://msdn.microsoft.com/en-us/library/jj129582.aspx
configuration = "VC1 Broadband SD 4x3";
Expand Down

0 comments on commit 6760316

Please sign in to comment.