/* * Copyright (c) 2023 Fancy Code. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this mFileAudio except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "SaveStream.h" #include "ILog.h" SaveStream::SaveStream() : mFileAudio(nullptr), mFileVideo(nullptr) { } void SaveStream::Init(void) { mFileAudio = fopen("/tmp/audio.g711", "a+"); // TODO: mFileVideo = fopen("/tmp/video.h264", "a+"); // TODO: } void SaveStream::UnInit(void) { if (mFileAudio) { fclose(mFileAudio); mFileAudio = nullptr; } if (mFileVideo) { fclose(mFileVideo); mFileVideo = nullptr; } } void SaveStream::GetVideoStream(const void *stream, const unsigned int &length, const unsigned long long &timeStamp) { if (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 unsigned int &length, const unsigned long long &timeStamp) { if (mFileAudio) { size_t writeLength = fwrite(stream, 1, length, mFileAudio); if (writeLength != length) { LogError("Write video stream failed.\n"); } fflush(mFileAudio); } }