April 28, 2011

gaucho gaucho
Lab Rat
7 posts

phonon on symbian

 

i’m new to QT. i’m tring to develop my first app on my nokia 5800 xm.
I installed all sdk (Qt SDK 1.1) and tools needed by qt on my windows desktop.
Then i built a empty qt mobility project where i added only a button.
The project (built on windows) runs without errors on my nokia.

In my project, i want to take an audio stream from microphone device and send
it to an output audio device.
I understood that i can use phonon class for my scope.

I only added on my mainWindow.cpp (at the beginning):

  1. #include <phonon/AudioOutput>

..and on the button action i added:

  1.  Phonon::AudioOutput* pAudioOutput;
  2.  
  3.  pAudioOutput = new Phonon::AudioOutput(  Phonon::MusicCategory,  this);

When i try to build the app i receive the following error:

warning: Can’t find following headers in User or System Include Paths:
“audiooutput.h”

but if i go in C:\QtSDK\Symbian\SDKs\Symbian1Qt473\include\phonon i can find the audiooutput.h

What is wrong in my environment?

my easy test project can be downloaded from www.tr3ma.com/Dati/test2.zip

11 replies

April 28, 2011

vinb vinb
Lab Rat
205 posts

Hi put this in your pro file please:
Qt += core gui phonon

April 29, 2011

leon.anavi leon.anavi
Mad Scientist
1045 posts

Wow… I just saw the same topic in Italian and used Google Translate to understand it :D

vinb suggestion is correct! I has able to build you demo project by adding this line to test2.pro :

  1. QT += core gui phonon

Best regards,
Leon

P.S.

Qt not QT :)

 Signature 

http://anavi.org/

April 29, 2011

gaucho gaucho
Lab Rat
7 posts

Thank you Bro,
Happy to know it’s not a dead forum.
now that it works,
i added the remaining part of the code in file mainWindow.cpp:

  1. #include <phonon/AudioOutput>
  2. #include <phonon/MediaObject>
  3. #include <phonon/MediaSource>

and in sub on_pushButton_clicked() i added:

  1.           Phonon::AudioOutput* pAudioOutput;
  2.           pAudioOutput = new Phonon::AudioOutput(  Phonon::MusicCategory,  this);
  3.           Phonon::MediaObject* pMediaObject ;
  4.           pMediaObject = new Phonon::MediaObject(this);
  5.           Phonon::createPath(pMediaObject, pAudioOutput);
  6.           QString url= QString("e:\\Scream.wav");
  7.           Phonon::MediaSource mediaSource = Phonon::MediaSource(url);
  8.           pMediaObject ->setCurrentSource( mediaSource);
  9.           pMediaObject->play();

then i copied the file Scream.wav in the external memory (e:)
I verified that i can listen to this file on the default player of the phone.
And when i run the code, and press the button, the phone plays the wav.
Very good.

Now: How can i change the output device, choosing from available outputs? (for example in case i have 2 bluetooth headphone connected, and i want to stream a file only to one of these headphone).
I’ll study on this question.

April 30, 2011

leon.anavi leon.anavi
Mad Scientist
1045 posts

Hi gaucho,

I am glad that the issue with audiooutput.h is solved.

gaucho wrote:
Now: How can i change the output device, choosing from available outputs? (for example in case i have 2 bluetooth headphone connected, and i want to stream a file only to one of these headphone). I’ll study on this question.

May be such a question deserves a separate thread :) I am not sure that Qt have such capabilities but if you are developing an app for Symbian (after all the forum title is Mobile and Embedded :) ) you can use Symbian C++ code to make “audio output routing “:http://wiki.forum.nokia.com/index.php/Audio_Routing_API_–_Input_and_Output

Cheers,
Leon

 Signature 

http://anavi.org/

April 30, 2011

gaucho gaucho
Lab Rat
7 posts

Thank you Leon,
i found that article yesterday, but may be it’s not the right class to use,
because the possible routes are only:

  1. enum TAudioOutputPreference   {
  2.  
  3. ENoPreference, /// Used to indicate that the playing audio can be routed to
  4.                        /// any speaker. This is the default value for audio.
  5.  
  6. EAll,                /// Used to indicate that the playing audio should be routed
  7.                       /// to all speakers.    
  8.  
  9. ENoOutput,     /// Used to indicate that the playing audio should not be routed
  10.                       /// to any output.          
  11.  
  12. EPrivate,         /// Used to indicate that the playing audio should be routed to
  13.                       /// the default private speaker. A private speaker is one that
  14.                       /// can only be heard by one person.    
  15.  
  16. EPublic,           /// Used to indicate that the playing audio should be routed to
  17.                       /// the default public speaker. A public speaker is one that can
  18.                       /// be heard by multiple people.  
  19. };

i can’t read in that article, how to obtain and select available devices.

Maybe instead,
i can obtain available output devices with the following:

  1. QList<Phonon::AudioOutputDevice> audioOutputDevices = Phonon::BackendCapabilities::availableAudioOutputDevices();

April 30, 2011

leon.anavi leon.anavi
Mad Scientist
1045 posts
gaucho wrote:
i can’t read in that article, how to obtain and select

According to this article you can route the audio output to the default private speaker (EPrivate) and there should not be more that one default private speaker.

gaucho wrote:

Maybe instead,
i can obtain available output devices with the following:

@QList<Phonon::AudioOutputDevice> audioOutputDevices = Phonon::BackendCapabilities::availableAudioOutputDevices();@

Did you manage to obtain available devices using this approach?

Best regards,
Leon

 Signature 

http://anavi.org/

May 4, 2011

gaucho gaucho
Lab Rat
7 posts

I added to my project a combobox,
then i added the following include:

  1. #include < phonon/BackendCapabilities >

and, on window creation routine, the following code:
  1.         QList<Phonon::AudioOutputDevice> devices = Phonon::BackendCapabilities::availableAudioOutputDevices();
  2.        
  3.         for (int i=0; i<devices.size(); i++){
  4.             QString itemText = devices[i].name();
  5.             if (!devices[i].description().isEmpty()) {
  6.                 itemText += QString::fromLatin1(" (%1)").arg(devices[i].description());
  7.             }
  8.             ui->comboBox->addItem(itemText);
  9.         }
The combobox populates with only one value, even if i connect a bluetooth headphone.

Am i doing something wrong? why i can’t obtain 2 output devices? Thank you.

May 4, 2011

leon.anavi leon.anavi
Mad Scientist
1045 posts

  1. QList<Phonon::AudioOutputDevice> devices = Phonon::BackendCapabilities::availableAudioOutputDevices();

Let’s ignore the GUI for a second. How many devices does the QList contain when you connect bluetooth headphone?

Regards,
Leon

 Signature 

http://anavi.org/

May 17, 2011

Chuck Gao Chuck Gao
Lab Rat
342 posts

hi, gaucho, you can try multimediakit.It’s more convenient on Symbian development

 Signature 

Chuck

May 17, 2011

gaucho gaucho
Lab Rat
7 posts

ok, if you know i can do these thigs i’ll try. (i’ll let you know).
may be i remember it wrong, but it seems to me that multimedia kit doesn’t allow you to select the output device, but only the output “type”.

May 17, 2011

Chuck Gao Chuck Gao
Lab Rat
342 posts
gaucho wrote:
ok, if you know i can do these thigs i’ll try. (i’ll let you know). may be i remember it wrong, but it seems to me that multimedia kit doesn’t allow you to select the output device, but only the output “type”.

you can get the device list via:
QList<QAudioDeviceInfo> QAudioDeviceInfo::availableDevices ( QAudio::Mode mode )
and use QAudioOutput to do the play work. You can also specify a output format. The only disadvantage i think, is the API didn’t support setVolume function.

 Signature 

Chuck

 
  ‹‹ Installing Qt framework on embedded Linux      QWS in Qt for Embedded Linux screen driver ››

You must log in to post a reply. Not a member yet? Register here!