How to set path to memory card of the mobile? - qt

I am using latest qt version 4.7,where i developed an application on Audio Recording.
I need to set the path to memory card(ie,mass memory),I have seen links based on carbide link->How to run C++ applications in symbian
But could not find any solution for this latest version.
Can anyone help me out in finding this!!
This is what i tried.
I used two methods but i am clueless….
But the audio file gets stored in simulator ,,but not in desired memory card location!!!
AudioBuffer::AudioBuffer()
{
audioSource = new QAudioCaptureSource();
capture = new QMediaRecorder(audioSource);
QAudioEncoderSettings audioSettings;
audioSettings.setCodec("audio/vorbis");
audioSettings.setQuality(QtMultimediaKit::HighQuality);
capture->setEncodingSettings(audioSettings);
capture->setOutputLocation(QUrl::fromLocalFile("test.wav"));
FileName path = PathInfo::MemoryCardRootPath();
path.Append( PathInfo::SoundsPath() );
// QFile file;
// QDir::setCurrent("/tmp");
// file.setFileName("test.wav");
// QDir::setCurrent("/home");
// file.open(QIODevice::ReadOnly);
}
I am using Symbian platform(Qt-Quick)
Regards,
Harish.

I don't develop applications for symbian platforms but IMHO you have to convert TDesC path to a QString (see Converting a Descriptor to a QString for details).

Internal memory is hardcoded to "E:/" and SD card is hardcoded to "F:/" on symbian.
Do a :
QDir d;
d.setPath("f:/");
if (d.exists()) {
[...]
}
to check the availability of the external storage

Related

Getting device information in class library with Uno Platform

I'm trying to develop a class library for use from Uno Platform applications that can be distributed as a NuGet package. In the code, I need to be able to extract various information about the device currently running the code. I already figured out how to get the screen dimensions but now I'm stuck in getting the current operating system and version. I have seen code like this:
#if __ANDROID__
os = "android";
#elif __IOS__
os = "ios";
#endif
But as I understand, this is not supported in class libraries. I have also experimented with the Uno port of Xamarin.Essentials to use the DeviceInfo class. I couldn't get this to work, though.
Any help would be appreciated.
I approach getting the OS info in a different manner. I grab the OS info using the following code:
public static string getOSVersion()
{
string osInfo = Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily.ToString();
int dotPosition = osInfo.IndexOf('.');
string shortOsInfo = osInfo.Substring(0, dotPosition);
return shortOsInfo + " " + Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamilyVersion.ToString();
}
If you are on Android- it will return Android 11, on IOS it will return iOS 14.4(Keep in mind the version number will probably be different- just using it for example purposes). I have not run this on WASM, UWP, Linux, or MacOS- but it should work. Hopefully this will be helpful to you!

Is it possible to transfer sqlite file to watch os 2

Can any one help me out on this problem. I am struggling to transfer the sqlite to watch os 2. If you have any example share with me or please give your suggestion on this
Have not tried this for sqlLite files but works with audioFiles.
What I did is:
Turn ON App Group both on watch extension and main project.
Place file in App Group Container
// I create the file there so my code is
NSURL * urlOut = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier: APP_CONECTIVITY_ID];
urlOut = [urlOut URLByAppendingPathComponent:#"myfile.wav"];
Send via WCSession sendMessage the link, need to send as string so you will send urlOut.absoluteString.
Profit?
You should be able to use stuff like sendMessageData //reading the file as date beforhand.
and there is also this WCSessionFileTransfer.
But I haven't had a chance to try that yet.

Audio Recording from a microphone to a wav file using Qt

I am trying to do an application with the purpose of being able to record phrases and have them automatically saved in a chosen directory as wav files. For this I am trying to use the QAudioRecorder class. When I hit the record button I speak something into the microphone and .wav file gets saved into the directory that I chose with the name that I want, but when I playback the file it is just noise. I don’t think I am using the recording class properly.
What I have so far is :
void RecordingWidget::startRecording()
{
if(audioRecorder->state() == QMediaRecorder::StoppedState)
{
//Set Audio Input
audioRecorder->setAudioInput(audioRecorder->defaultAudioInput());
// Sets Output location where to store the file
if(!m_outputLocationSet)
setOutputLocation();
// Set recording Settings
QAudioEncoderSettings settings;
settings.setCodec("audio/amr"); // Not sure what to put here
settings.setSampleRate(16000);
settings.setBitRate(32);
settings.setQuality(QMultimedia::HighQuality);
settings.setEncodingMode(QMultimedia::ConstantQualityEncoding);
audioRecorder->setEncodingSettings(settings);
audioRecorder->record();
}
else {
stopRecording();
}
}
Can anyone please help me out, any guidance greatly appreciated! Thanks.

QAudioOutput in Qt5 is not producing any sound

I’m working under kubuntu 12.10 and developping an application into which i need to generate some sound into a QIODevice, then play it with QAudioOutput.
I’ve read all the litterature around speaking of how to properly do that, and I think to have done so.
So far I’ve done :
QVector <double> * soundData = SoundGenerator::getSound();
soundBuffer->open(QIODevice::ReadWrite);
QDataStream writeStream(soundBuffer);
foreach(double d, *soundData) {
char value = d * (2 << 7);
// qDebug() << "Value : " << (short int)value;
writeStream << value;
}
QAudioFormat format;
// Set up the format, eg.
format.setSampleRate(SoundGenerator::getAudioSampleRate());
format.setChannelCount(1);
format.setSampleSize(8);
format.setCodec("audio/pcm");
format.setByteOrder(QAudioFormat::LittleEndian);
format.setSampleType(QAudioFormat::SignedInt);
QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
audio = new QAudioOutput(format, this);
if (audio->error() != QAudio::NoError) {
qDebug() << "Problem playing sound";
}
connect(audio, SIGNAL(stateChanged(QAudio::State)), this, SLOT(aboutToFinish(QAudio::State)));
I have also a call to
audio->start(soundBuffer)
—
from another slot
I do not have any error in the initialization of the QAudioOutput
And I have NO SOUND AT ALL (all other applications have sound, and I’m porting a Qt4 app to Qt5, in Qt4 everything is ok with Phonon)
The aboutToFinish slot is called at the beggining with ActiveState as state, and NoError when calling QAudioOutput::error, but it’s not called anymore, even if waiting far more than the expected generated sound duration.
The sound generation process is not to be put in question, it has been tested by writing wav files, and it works.
Moreover, I have built the multimedia example from Qt’s sources, when it comes to pure audio there is no output (for example in the sprectrum example), on another hand, video plays with the sound perfectly.
Is there any known issue concerning that ? Is that a bug ? Am I doing something wrong ?
Thanks in advance ;)
This does not work because you have set 8 bit sample size and signed integer format.
SOLUTION: You have to set the sample type to unsigned for 8-bit resolution:
format.setSampleType(QAudioFormat::UnsignedInt);
This is not a Qt bug. Why? The answer is that in the WAV spec', 8-bit samples are always unsigned, whereas 16-bit samples are always signed. Any other combination does not work.
So for 16-bit samples you would have to put:
format.setSampleType(QAudioFormat:SignedInt);
(IMHO the fact that Qt does not take care of handling these cases by forcing the correct format is a flaw but not a lack in functionnality).
You can learn more about this in the notes section of this page: https://ccrma.stanford.edu/courses/422/projects/WaveFormat/
And also the solution to this very similar question (same problem but with 16-bit): Qt QAudioOutput push mode
Try to add:
QEventLoop loop;
loop.exec();

Streaming webcam video in Flash using MP4 encoding

One of the features of the Flash app I'm working on is to be able to stream a webcam to others. We're just using the built-in webcam support in Flash and sending it through FMS.
We've had some people ask for higher quality video, but we're already using the highest quality setting we can in Flash (setting quality to 100%).
My understanding is that in the newer flash players they added support for MPEG-4 encoding for the videos. I created a simple test Flex app to try and compare the video quality of the MP4 vs FLV encodings. However, I can't seem to get MP4 to work at all.
According to the Flex documentation the only thing I need to do to use MP4 instead of FLV is prepend "mp4:" to the name of the stream when calling publish:
Specify the stream name as a string
with the prefix mp4: with or without
the filename extension. The prefix
indicates to the server that the file
contains H.264-encoded video and
AAC-encoded audio within the MPEG-4
Part 14 container format.
When I try this nothing happens. I don't get any events raised on the client side, no exceptions thrown, and my logging on the server side doesn't show any streams starting.
Here's the relevant code:
// These are all defined and created within the class.
private var nc:NetConnection;
private var sharing:Boolean;
private var pubStream:NetStream;
private var format:String;
private var streamName:String;
private var camera:Camera;
// called when the user clicks the start button
private function startSharing():void {
if (!nc.connected) {
return;
}
if (sharing) { return; }
if(pubStream == null) {
pubStream = new NetStream(nc);
pubStream.attachCamera(camera);
}
startPublish();
sharing = true;
}
private function startPublish():void {
var name:String;
if (this.format == "mp4") {
name = "mp4:" + streamName;
} else {
name = streamName;
}
//pubStream.publish(name, "live");
pubStream.publish(name, "record");
}
Would be helpful to know the version of FMS you are running?
It seems like you need at least FMS 3.0.2.
Are you sure this applies to live streams and not only for recording? this 1 2 links suggest that while the player can decode sorenson, vp6 and h264, it can only encode in sorenson.
I'm in a similar situation, so I would like to have this clarified.
edit: what actually makes me doubt is that the documentation says flv and mp4, which arent codecs but containers, live streaming doesnt use containers, the encoded frames travel directly inside rtmp packets
Flash Player doesn't encode using H.264, but Flash Media Server can record any codec in the F4V container. Flash Media Live Encoder can encode using H.264.
So basically you can't send h264 from web flash player (yet?)...

Resources