Fixed:media callback function bug.

This commit is contained in:
Fancy code 2024-06-15 14:12:06 +08:00
parent 113275600c
commit 2c9a659d4c
2 changed files with 11 additions and 4 deletions

View File

@ -25,9 +25,9 @@ void MediaHandle::Init(void)
LogError("CameraHal is null.\n");
return;
}
auto audioFunc = std::bind(&MediaHandle::GetVideoStreamCallback, this, _1, _2, _3);
auto audioFunc = std::bind(&MediaHandle::GetAudioStreamCallback, this, _1, _2, _3);
mCameraHal->SetAudioStreamCallback(audioFunc);
auto videoFunc = std::bind(&MediaHandle::GetAudioStreamCallback, this, _1, _2, _3);
auto videoFunc = std::bind(&MediaHandle::GetVideoStreamCallback, this, _1, _2, _3);
mCameraHal->SetVideoStreamCallback(videoFunc);
}
void MediaHandle::UnInit(void)

View File

@ -13,6 +13,7 @@
* limitations under the License.
*/
#include "SaveStream.h"
#include "ILog.h"
SaveStream::SaveStream() : mFileAudio(nullptr), mFileVideo(nullptr)
{
}
@ -35,14 +36,20 @@ void SaveStream::UnInit(void)
void SaveStream::GetVideoStream(const void *stream, const int &length, const unsigned long long &timeStamp)
{
if (mFileVideo) {
fwrite(stream, 1, length, mFileVideo);
size_t writeLength = fwrite(stream, 1, length, mFileVideo);
if (writeLength != length) {
LogError("Write video stream failed.\n");
}
fflush(mFileVideo);
}
}
void SaveStream::GetAudioStream(const void *stream, const int &length, const unsigned long long &timeStamp)
{
if (mFileAudio) {
fwrite(stream, 1, length, mFileAudio);
size_t writeLength = fwrite(stream, 1, length, mFileAudio);
if (writeLength != length) {
LogError("Write video stream failed.\n");
}
fflush(mFileAudio);
}
}