1b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi/* 2b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi * Copyright (C) 2011 The Android Open Source Project 3b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi * 4b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi * Licensed under the Apache License, Version 2.0 (the "License"); 5b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi * you may not use this file except in compliance with the License. 6b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi * You may obtain a copy of the License at 7b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi * 8b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi * http://www.apache.org/licenses/LICENSE-2.0 9b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi * 10b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi * Unless required by applicable law or agreed to in writing, software 11b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi * distributed under the License is distributed on an "AS IS" BASIS, 12b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi * See the License for the specific language governing permissions and 14b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi * limitations under the License. 15b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi */ 16b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi 17b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi/** 18b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi * Test for testing the creation of OpenMAX AL objects. 19b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi * The tests verify the creation and completion of the call to Realize() for the following objects: 20b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi * - Engine 21b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi * - OutputMix 22b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi */ 23b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi 24b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi#define LOG_NDEBUG 0 25b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi#define LOG_TAG "XAObjectCreationTest" 26b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi 272830d721b4173ac7a91e4fc8b9cc0cafaaf86460Christopher Ferris#include <gtest/gtest.h> 28b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi#include <utils/Log.h> 292830d721b4173ac7a91e4fc8b9cc0cafaaf86460Christopher Ferris 30b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi#include "OMXAL/OpenMAXAL.h" 31b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi#include "OMXAL/OpenMAXAL_Android.h" 32b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi 33b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi//----------------------------------------------------------------- 34b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi/* Checks for error and displays the error code if any */ 35b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivibool IsOk(XAresult res) { 36b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi if (XA_RESULT_SUCCESS != res) { 37b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi fprintf(stderr, "IsOk failure: 0x%x, exiting\n", res); 38b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi return false; 39b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi } 40b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi return true; 41b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi} 42b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi 43b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi//----------------------------------------------------------------- 44b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Triviclass XAObjectCreationTest : public ::testing::Test { 45b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi 46b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Triviprotected: 47b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi XAresult res; 48b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi XAObjectItf engineObj, outputMixObj, mediaPlayerObj; 49b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi XAEngineItf engineItf; 50b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi 51b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi XADataSource mediaSource; 52b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi XADataSink audioSink; 53b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi XADataLocator_URI locatorUriSrc; 54b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi XADataLocator_AndroidBufferQueue locatorAbqSrc; 55b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi XADataLocator_AndroidFD locatorFdSrc; 56b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi XADataFormat_MIME formatMimeSrc; 57b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi 58b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi XADataLocator_OutputMix locatorOutputmixSink; 59b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi XADataFormat_PCM formatPcmSink; 60b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi 61b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi XADataLocator_NativeDisplay locatorVideoSink; 62b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi XADataSink imageSink; 63b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi 64b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi //ANativeWindow* pNativeWindow; 65b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi 66b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi XAObjectCreationTest() { } 67b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi 68b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi virtual ~XAObjectCreationTest() { } 69b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi 70b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi /* Test setup*/ 71b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi virtual void SetUp() { 72b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi ALOGV("Test Setup()"); 73b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi res = XA_RESULT_UNKNOWN_ERROR; 74b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi engineItf = NULL; 75b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi engineObj = NULL; 76b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi outputMixObj = NULL; 77b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi mediaPlayerObj = NULL; 78b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi // Engine creation 79b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi res = xaCreateEngine(&engineObj, 0, NULL, 0, NULL, NULL); 80b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi ASSERT_TRUE(IsOk(res)); 81b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi res = (*engineObj)->Realize(engineObj, XA_BOOLEAN_FALSE); 82b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi ASSERT_TRUE(IsOk(res)); 83b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi res = (*engineObj)->GetInterface(engineObj, XA_IID_ENGINE, &engineItf); 84b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi ASSERT_TRUE(IsOk(res)); 85b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi ASSERT_TRUE(NULL != engineItf); 86b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi } 87b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi 88b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi virtual void TearDown() { 89b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi ALOGV("Test TearDown()"); 90b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi if (mediaPlayerObj) { 91b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi (*mediaPlayerObj)->Destroy(mediaPlayerObj); 92b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi mediaPlayerObj = NULL; 93b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi } 94b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi if (outputMixObj) { 95b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi (*outputMixObj)->Destroy(outputMixObj); 96b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi outputMixObj = NULL; 97b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi } 98b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi if (engineObj){ 99b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi (*engineObj)->Destroy(engineObj); 100b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi engineObj = NULL; 101b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi } 102b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi } 103b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi 104b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi //--------------------------------------------------------------------------------------------- 105b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi // Tests 106b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi 107b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi /* Test case for creating an MediaPlayer object */ 108b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi void OutputMixCreation() { 109b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi res = (*engineItf)->CreateOutputMix(engineItf, &outputMixObj, 110b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi 0, NULL/*iidArray*/, NULL/*required*/); 111b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi ASSERT_TRUE(IsOk(res)); 112b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi ASSERT_TRUE(NULL != outputMixObj); 113b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi res = (*outputMixObj)->Realize(outputMixObj, XA_BOOLEAN_FALSE); 114b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi ASSERT_TRUE(IsOk(res)); 115b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi } 116b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi 117b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi}; 118b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi 119b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi//------------------------------------------------------------------------------------------------- 120b683513665956ff9a06f84ebd765637491aeb78cJean-Michel TriviTEST_F(XAObjectCreationTest, testEngineCreation) { 121b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi ALOGV("Test Fixture: EngineCreation"); 122b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi // nothing to do here that isn't done in SetUp() 123b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi} 124b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi 125b683513665956ff9a06f84ebd765637491aeb78cJean-Michel TriviTEST_F(XAObjectCreationTest, testOutputMixCreation) { 126b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi ALOGV("Test Fixture: OutputMixCreation"); 127b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi OutputMixCreation(); 128b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi} 129b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi 130b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Triviint main(int argc, char **argv) { 131b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi testing::InitGoogleTest(&argc, argv); 132b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi 133b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi return RUN_ALL_TESTS(); 134b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi} 135b683513665956ff9a06f84ebd765637491aeb78cJean-Michel Trivi 136