VirtualBox

source: vbox/trunk/src/VBox/Main/src-client/DrvAudioVideoRec.cpp@ 74901

Last change on this file since 74901 was 74851, checked in by vboxsync, 6 years ago

Build fix for debug build.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 38.2 KB
Line 
1/* $Id: DrvAudioVideoRec.cpp 74851 2018-10-15 17:21:13Z vboxsync $ */
2/** @file
3 * Video recording audio backend for Main.
4 */
5
6/*
7 * Copyright (C) 2016-2018 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18/* This code makes use of the Opus codec (libopus):
19 *
20 * Copyright 2001-2011 Xiph.Org, Skype Limited, Octasic,
21 * Jean-Marc Valin, Timothy B. Terriberry,
22 * CSIRO, Gregory Maxwell, Mark Borgerding,
23 * Erik de Castro Lopo
24 *
25 * Redistribution and use in source and binary forms, with or without
26 * modification, are permitted provided that the following conditions
27 * are met:
28 *
29 * - Redistributions of source code must retain the above copyright
30 * notice, this list of conditions and the following disclaimer.
31 *
32 * - Redistributions in binary form must reproduce the above copyright
33 * notice, this list of conditions and the following disclaimer in the
34 * documentation and/or other materials provided with the distribution.
35 *
36 * - Neither the name of Internet Society, IETF or IETF Trust, nor the
37 * names of specific contributors, may be used to endorse or promote
38 * products derived from this software without specific prior written
39 * permission.
40 *
41 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
42 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
43 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
44 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
45 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
46 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
47 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
48 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
49 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
50 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
51 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
52 *
53 * Opus is subject to the royalty-free patent licenses which are
54 * specified at:
55 *
56 * Xiph.Org Foundation:
57 * https://datatracker.ietf.org/ipr/1524/
58 *
59 * Microsoft Corporation:
60 * https://datatracker.ietf.org/ipr/1914/
61 *
62 * Broadcom Corporation:
63 * https://datatracker.ietf.org/ipr/1526/
64 *
65 */
66
67/**
68 * This driver is part of Main and is responsible for providing audio
69 * data to Main's video capturing feature.
70 *
71 * The driver itself implements a PDM host audio backend, which in turn
72 * provides the driver with the required audio data and audio events.
73 *
74 * For now there is support for the following destinations (called "sinks"):
75 *
76 * - Direct writing of .webm files to the host.
77 * - Communicating with Main via the Console object to send the encoded audio data to.
78 * The Console object in turn then will route the data to the Display / video capturing interface then.
79 */
80
81
82/*********************************************************************************************************************************
83* Header Files *
84*********************************************************************************************************************************/
85#define LOG_GROUP LOG_GROUP_DRV_HOST_AUDIO
86#include "LoggingNew.h"
87
88#include "DrvAudioVideoRec.h"
89#include "ConsoleImpl.h"
90
91#include "../../Devices/Audio/DrvAudio.h"
92#include "WebMWriter.h"
93
94#include <iprt/mem.h>
95#include <iprt/cdefs.h>
96
97#include <VBox/vmm/pdmaudioifs.h>
98#include <VBox/vmm/pdmdrv.h>
99#include <VBox/vmm/cfgm.h>
100#include <VBox/err.h>
101
102#ifdef VBOX_WITH_LIBOPUS
103# include <opus.h>
104#endif
105
106
107/*********************************************************************************************************************************
108* Defines *
109*********************************************************************************************************************************/
110
111#define AVREC_OPUS_HZ_MAX 48000 /** Maximum sample rate (in Hz) Opus can handle. */
112
113
114/*********************************************************************************************************************************
115* Structures and Typedefs *
116*********************************************************************************************************************************/
117
118/**
119 * Enumeration for specifying the recording container type.
120 */
121typedef enum AVRECCONTAINERTYPE
122{
123 /** Unknown / invalid container type. */
124 AVRECCONTAINERTYPE_UNKNOWN = 0,
125 /** Recorded data goes to Main / Console. */
126 AVRECCONTAINERTYPE_MAIN_CONSOLE = 1,
127 /** Recorded data will be written to a .webm file. */
128 AVRECCONTAINERTYPE_WEBM = 2
129} AVRECCONTAINERTYPE;
130
131/**
132 * Structure for keeping generic container parameters.
133 */
134typedef struct AVRECCONTAINERPARMS
135{
136 /** The container's type. */
137 AVRECCONTAINERTYPE enmType;
138
139} AVRECCONTAINERPARMS, *PAVRECCONTAINERPARMS;
140
141/**
142 * Structure for keeping container-specific data.
143 */
144typedef struct AVRECCONTAINER
145{
146 /** Generic container parameters. */
147 AVRECCONTAINERPARMS Parms;
148
149 union
150 {
151 struct
152 {
153 /** Pointer to Console. */
154 Console *pConsole;
155 } Main;
156
157 struct
158 {
159 /** Pointer to WebM container to write recorded audio data to.
160 * See the AVRECMODE enumeration for more information. */
161 WebMWriter *pWebM;
162 /** Assigned track number from WebM container. */
163 uint8_t uTrack;
164 } WebM;
165 };
166} AVRECCONTAINER, *PAVRECCONTAINER;
167
168/**
169 * Structure for keeping generic codec parameters.
170 */
171typedef struct AVRECCODECPARMS
172{
173 /** The codec's used PCM properties. */
174 PDMAUDIOPCMPROPS PCMProps;
175 /** The codec's bitrate. 0 if not used / cannot be specified. */
176 uint32_t uBitrate;
177
178} AVRECCODECPARMS, *PAVRECCODECPARMS;
179
180/**
181 * Structure for keeping codec-specific data.
182 */
183typedef struct AVRECCODEC
184{
185 /** Generic codec parameters. */
186 AVRECCODECPARMS Parms;
187 union
188 {
189#ifdef VBOX_WITH_LIBOPUS
190 struct
191 {
192 /** Encoder we're going to use. */
193 OpusEncoder *pEnc;
194 /** Time (in ms) an (encoded) frame takes.
195 *
196 * For Opus, valid frame sizes are:
197 * ms Frame size
198 * 2.5 120
199 * 5 240
200 * 10 480
201 * 20 (Default) 960
202 * 40 1920
203 * 60 2880
204 */
205 uint32_t msFrame;
206 } Opus;
207#endif /* VBOX_WITH_LIBOPUS */
208 };
209
210#ifdef VBOX_WITH_STATISTICS /** @todo Make these real STAM values. */
211 struct
212 {
213 /** Number of frames encoded. */
214 uint64_t cEncFrames;
215 /** Total time (in ms) of already encoded audio data. */
216 uint64_t msEncTotal;
217 } STAM;
218#endif /* VBOX_WITH_STATISTICS */
219
220} AVRECCODEC, *PAVRECCODEC;
221
222typedef struct AVRECSINK
223{
224 /** @todo Add types for container / codec as soon as we implement more stuff. */
225
226 /** Container data to use for data processing. */
227 AVRECCONTAINER Con;
228 /** Codec data this sink uses for encoding. */
229 AVRECCODEC Codec;
230 /** Timestamp (in ms) of when the sink was created. */
231 uint64_t tsStartMs;
232} AVRECSINK, *PAVRECSINK;
233
234/**
235 * Audio video recording (output) stream.
236 */
237typedef struct AVRECSTREAM
238{
239 /** The stream's acquired configuration. */
240 PPDMAUDIOSTREAMCFG pCfg;
241 /** (Audio) frame buffer. */
242 PRTCIRCBUF pCircBuf;
243 /** Pointer to sink to use for writing. */
244 PAVRECSINK pSink;
245 /** Last encoded PTS (in ms). */
246 uint64_t uLastPTSMs;
247} AVRECSTREAM, *PAVRECSTREAM;
248
249/**
250 * Video recording audio driver instance data.
251 */
252typedef struct DRVAUDIOVIDEOREC
253{
254 /** Pointer to audio video recording object. */
255 AudioVideoRec *pAudioVideoRec;
256 /** Pointer to the driver instance structure. */
257 PPDMDRVINS pDrvIns;
258 /** Pointer to host audio interface. */
259 PDMIHOSTAUDIO IHostAudio;
260 /** Pointer to the console object. */
261 ComPtr<Console> pConsole;
262 /** Pointer to the DrvAudio port interface that is above us. */
263 PPDMIAUDIOCONNECTOR pDrvAudio;
264 /** The driver's sink for writing output to. */
265 AVRECSINK Sink;
266} DRVAUDIOVIDEOREC, *PDRVAUDIOVIDEOREC;
267
268/** Makes DRVAUDIOVIDEOREC out of PDMIHOSTAUDIO. */
269#define PDMIHOSTAUDIO_2_DRVAUDIOVIDEOREC(pInterface) /* (clang doesn't think it is a POD, thus _DYN.) */ \
270 ( (PDRVAUDIOVIDEOREC)((uintptr_t)pInterface - RT_UOFFSETOF_DYN(DRVAUDIOVIDEOREC, IHostAudio)) )
271
272/**
273 * Initializes a recording sink.
274 *
275 * @returns IPRT status code.
276 * @param pThis Driver instance.
277 * @param pSink Sink to initialize.
278 * @param pConParms Container parameters to set.
279 * @param pCodecParms Codec parameters to set.
280 */
281static int avRecSinkInit(PDRVAUDIOVIDEOREC pThis, PAVRECSINK pSink, PAVRECCONTAINERPARMS pConParms, PAVRECCODECPARMS pCodecParms)
282{
283 uint32_t uHz = pCodecParms->PCMProps.uHz;
284 uint8_t cBytes = pCodecParms->PCMProps.cBytes;
285 uint8_t cChannels = pCodecParms->PCMProps.cChannels;
286 uint32_t uBitrate = pCodecParms->uBitrate;
287
288 /* Opus only supports certain input sample rates in an efficient manner.
289 * So make sure that we use those by resampling the data to the requested rate. */
290 if (uHz > 24000) uHz = AVREC_OPUS_HZ_MAX;
291 else if (uHz > 16000) uHz = 24000;
292 else if (uHz > 12000) uHz = 16000;
293 else if (uHz > 8000 ) uHz = 12000;
294 else uHz = 8000;
295
296 if (cChannels > 2)
297 {
298 LogRel(("VideoRec: More than 2 (stereo) channels are not supported at the moment\n"));
299 cChannels = 2;
300 }
301
302 LogRel2(("VideoRec: Recording audio in %RU16Hz, %RU8 channels\n", uHz, cChannels));
303
304 int orc;
305 OpusEncoder *pEnc = opus_encoder_create(uHz, cChannels, OPUS_APPLICATION_AUDIO, &orc);
306 if (orc != OPUS_OK)
307 {
308 LogRel(("VideoRec: Audio codec failed to initialize: %s\n", opus_strerror(orc)));
309 return VERR_AUDIO_BACKEND_INIT_FAILED;
310 }
311
312 AssertPtr(pEnc);
313
314 if (uBitrate) /* Only explicitly set the bitrate if we specified one. Otherwise let Opus decide. */
315 {
316 opus_encoder_ctl(pEnc, OPUS_SET_BITRATE(uBitrate));
317 if (orc != OPUS_OK)
318 {
319 opus_encoder_destroy(pEnc);
320 pEnc = NULL;
321
322 LogRel(("VideoRec: Audio codec failed to set bitrate (%RU32): %s\n", uBitrate, opus_strerror(orc)));
323 return VERR_AUDIO_BACKEND_INIT_FAILED;
324 }
325 }
326
327 const bool fUseVBR = true; /** Use Variable Bit Rate (VBR) by default. @todo Make this configurable? */
328
329 orc = opus_encoder_ctl(pEnc, OPUS_SET_VBR(fUseVBR ? 1 : 0));
330 if (orc != OPUS_OK)
331 {
332 opus_encoder_destroy(pEnc);
333 pEnc = NULL;
334
335 LogRel(("VideoRec: Audio codec failed to %s VBR mode: %s\n", fUseVBR ? "enable" : "disable", opus_strerror(orc)));
336 return VERR_AUDIO_BACKEND_INIT_FAILED;
337 }
338
339 int rc = VINF_SUCCESS;
340
341 try
342 {
343 switch (pConParms->enmType)
344 {
345 case AVRECCONTAINERTYPE_MAIN_CONSOLE:
346 {
347 if (pThis->pConsole)
348 {
349 pSink->Con.Main.pConsole = pThis->pConsole;
350 }
351 else
352 rc = VERR_NOT_SUPPORTED;
353 break;
354 }
355
356 case AVRECCONTAINERTYPE_WEBM:
357 {
358#ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA
359 /* If we only record audio, create our own WebM writer instance here. */
360 if (!pSink->Con.WebM.pWebM) /* Do we already have our WebM writer instance? */
361 {
362 char szFile[RTPATH_MAX];
363 if (RTStrPrintf(szFile, sizeof(szFile), "%s%s",
364 VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH, "DrvAudioVideoRec.webm"))
365 {
366 /** @todo Add sink name / number to file name. */
367
368 pSink->Con.WebM.pWebM = new WebMWriter();
369 rc = pSink->Con.WebM.pWebM->Create(szFile,
370 /** @todo Add option to add some suffix if file exists instead of overwriting? */
371 RTFILE_O_CREATE_REPLACE | RTFILE_O_WRITE | RTFILE_O_DENY_NONE,
372 WebMWriter::AudioCodec_Opus, WebMWriter::VideoCodec_None);
373 if (RT_SUCCESS(rc))
374 {
375 rc = pSink->Con.WebM.pWebM->AddAudioTrack(uHz, cChannels, cBytes * 8 /* Bits */,
376 &pSink->Con.WebM.uTrack);
377 if (RT_SUCCESS(rc))
378 {
379 LogRel(("VideoRec: Recording audio to file '%s'\n", szFile));
380 }
381 else
382 LogRel(("VideoRec: Error creating audio track for file '%s' (%Rrc)\n", szFile, rc));
383 }
384 else
385 LogRel(("VideoRec: Error creating audio file '%s' (%Rrc)\n", szFile, rc));
386 }
387 else
388 {
389 AssertFailed(); /* Should never happen. */
390 LogRel(("VideoRec: Error creating audio file path\n"));
391 }
392 }
393#else
394 rc = VERR_NOT_SUPPORTED;
395#endif /* VBOX_AUDIO_DEBUG_DUMP_PCM_DATA */
396 break;
397 }
398
399 default:
400 rc = VERR_NOT_SUPPORTED;
401 break;
402 }
403 }
404 catch (std::bad_alloc &)
405 {
406#ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA
407 rc = VERR_NO_MEMORY;
408#endif
409 }
410
411 if (RT_SUCCESS(rc))
412 {
413 pSink->Con.Parms.enmType = pConParms->enmType;
414
415 pSink->Codec.Parms.PCMProps.uHz = uHz;
416 pSink->Codec.Parms.PCMProps.cChannels = cChannels;
417 pSink->Codec.Parms.PCMProps.cBytes = cBytes;
418 pSink->Codec.Parms.PCMProps.cShift = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(pSink->Codec.Parms.PCMProps.cBytes,
419 pSink->Codec.Parms.PCMProps.cChannels);
420 pSink->Codec.Parms.uBitrate = uBitrate;
421
422 pSink->Codec.Opus.pEnc = pEnc;
423 pSink->Codec.Opus.msFrame = 20; /** @todo 20 ms of audio data. Make this configurable? */
424
425#ifdef VBOX_WITH_STATISTICS
426 pSink->Codec.STAM.cEncFrames = 0;
427 pSink->Codec.STAM.msEncTotal = 0;
428#endif
429
430 pSink->tsStartMs = RTTimeMilliTS();
431 }
432 else
433 {
434 if (pEnc)
435 {
436 opus_encoder_destroy(pEnc);
437 pEnc = NULL;
438 }
439
440 LogRel(("VideoRec: Error creating sink (%Rrc)\n", rc));
441 }
442
443 return rc;
444}
445
446
447/**
448 * Shuts down (closes) a recording sink,
449 *
450 * @returns IPRT status code.
451 * @param pSink Recording sink to shut down.
452 */
453static void avRecSinkShutdown(PAVRECSINK pSink)
454{
455 AssertPtrReturnVoid(pSink);
456
457#ifdef VBOX_WITH_LIBOPUS
458 if (pSink->Codec.Opus.pEnc)
459 {
460 opus_encoder_destroy(pSink->Codec.Opus.pEnc);
461 pSink->Codec.Opus.pEnc = NULL;
462 }
463#endif
464 switch (pSink->Con.Parms.enmType)
465 {
466 case AVRECCONTAINERTYPE_WEBM:
467 {
468 if (pSink->Con.WebM.pWebM)
469 {
470 LogRel2(("VideoRec: Finished recording audio to file '%s' (%zu bytes)\n",
471 pSink->Con.WebM.pWebM->GetFileName().c_str(), pSink->Con.WebM.pWebM->GetFileSize()));
472
473 int rc2 = pSink->Con.WebM.pWebM->Close();
474 AssertRC(rc2);
475
476 delete pSink->Con.WebM.pWebM;
477 pSink->Con.WebM.pWebM = NULL;
478 }
479 break;
480 }
481
482 case AVRECCONTAINERTYPE_MAIN_CONSOLE:
483 default:
484 break;
485 }
486}
487
488
489/**
490 * Creates an audio output stream and associates it with the specified recording sink.
491 *
492 * @returns IPRT status code.
493 * @param pThis Driver instance.
494 * @param pStreamAV Audio output stream to create.
495 * @param pSink Recording sink to associate audio output stream to.
496 * @param pCfgReq Requested configuration by the audio backend.
497 * @param pCfgAcq Acquired configuration by the audio output stream.
498 */
499static int avRecCreateStreamOut(PDRVAUDIOVIDEOREC pThis, PAVRECSTREAM pStreamAV,
500 PAVRECSINK pSink, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq)
501{
502 AssertPtrReturn(pThis, VERR_INVALID_POINTER);
503 AssertPtrReturn(pStreamAV, VERR_INVALID_POINTER);
504 AssertPtrReturn(pSink, VERR_INVALID_POINTER);
505 AssertPtrReturn(pCfgReq, VERR_INVALID_POINTER);
506 AssertPtrReturn(pCfgAcq, VERR_INVALID_POINTER);
507
508 if (pCfgReq->DestSource.Dest != PDMAUDIOPLAYBACKDEST_FRONT)
509 {
510 AssertFailed();
511
512 LogRel2(("VideoRec: Support for surround audio not implemented yet\n"));
513 return VERR_NOT_SUPPORTED;
514 }
515
516 int rc = VINF_SUCCESS;
517
518#ifdef VBOX_WITH_LIBOPUS
519 const unsigned cFrames = 2; /** @todo Use the PreRoll param for that? */
520
521 const uint32_t csFrame = pSink->Codec.Parms.PCMProps.uHz / (1000 /* s in ms */ / pSink->Codec.Opus.msFrame);
522 const uint32_t cbFrame = DrvAudioHlpFramesToBytes(csFrame, &pSink->Codec.Parms.PCMProps);
523
524 rc = RTCircBufCreate(&pStreamAV->pCircBuf, cbFrame * cFrames);
525 if (RT_SUCCESS(rc))
526 {
527 pStreamAV->pSink = pSink; /* Assign sink to stream. */
528 pStreamAV->uLastPTSMs = 0;
529
530 if (pCfgAcq)
531 {
532 /* Make sure to let the driver backend know that we need the audio data in
533 * a specific sampling rate Opus is optimized for. */
534 pCfgAcq->Props.uHz = pSink->Codec.Parms.PCMProps.uHz;
535 pCfgAcq->Props.cShift = PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(pCfgAcq->Props.cBytes, pCfgAcq->Props.cChannels);
536
537 /* Every Opus frame marks a period for now. Optimize this later. */
538 pCfgAcq->Backend.cfPeriod = DrvAudioHlpMilliToFrames(pSink->Codec.Opus.msFrame, &pCfgAcq->Props);
539 pCfgAcq->Backend.cfBufferSize = DrvAudioHlpMilliToFrames(100 /* ms */, &pCfgAcq->Props); /** @todo Make this configurable. */
540 pCfgAcq->Backend.cfPreBuf = pCfgAcq->Backend.cfPeriod * 2;
541 }
542 }
543#else
544 RT_NOREF(pThis, pSink, pStreamAV, pCfgReq, pCfgAcq);
545 rc = VERR_NOT_SUPPORTED;
546#endif /* VBOX_WITH_LIBOPUS */
547
548 LogFlowFuncLeaveRC(rc);
549 return rc;
550}
551
552
553/**
554 * Destroys (closes) an audio output stream.
555 *
556 * @returns IPRT status code.
557 * @param pThis Driver instance.
558 * @param pStreamAV Audio output stream to destroy.
559 */
560static int avRecDestroyStreamOut(PDRVAUDIOVIDEOREC pThis, PAVRECSTREAM pStreamAV)
561{
562 RT_NOREF(pThis);
563
564 if (pStreamAV->pCircBuf)
565 {
566 RTCircBufDestroy(pStreamAV->pCircBuf);
567 pStreamAV->pCircBuf = NULL;
568 }
569
570 return VINF_SUCCESS;
571}
572
573
574/**
575 * Controls an audio output stream
576 *
577 * @returns IPRT status code.
578 * @param pThis Driver instance.
579 * @param pStreamAV Audio output stream to control.
580 * @param enmStreamCmd Stream command to issue.
581 */
582static int avRecControlStreamOut(PDRVAUDIOVIDEOREC pThis,
583 PAVRECSTREAM pStreamAV, PDMAUDIOSTREAMCMD enmStreamCmd)
584{
585 RT_NOREF(pThis, pStreamAV);
586
587 int rc = VINF_SUCCESS;
588
589 switch (enmStreamCmd)
590 {
591 case PDMAUDIOSTREAMCMD_ENABLE:
592 case PDMAUDIOSTREAMCMD_DISABLE:
593 case PDMAUDIOSTREAMCMD_RESUME:
594 case PDMAUDIOSTREAMCMD_PAUSE:
595 break;
596
597 default:
598 rc = VERR_NOT_SUPPORTED;
599 break;
600 }
601
602 return rc;
603}
604
605
606/**
607 * @interface_method_impl{PDMIHOSTAUDIO,pfnInit}
608 */
609static DECLCALLBACK(int) drvAudioVideoRecInit(PPDMIHOSTAUDIO pInterface)
610{
611 AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
612
613 LogFlowFuncEnter();
614
615 PDRVAUDIOVIDEOREC pThis = PDMIHOSTAUDIO_2_DRVAUDIOVIDEOREC(pInterface);
616
617 AVRECCONTAINERPARMS ContainerParms;
618 ContainerParms.enmType = AVRECCONTAINERTYPE_MAIN_CONSOLE; /** @todo Make this configurable. */
619
620 AVRECCODECPARMS CodecParms;
621 CodecParms.PCMProps.uHz = AVREC_OPUS_HZ_MAX; /** @todo Make this configurable. */
622 CodecParms.PCMProps.cChannels = 2; /** @todo Make this configurable. */
623 CodecParms.PCMProps.cBytes = 2; /** 16 bit @todo Make this configurable. */
624
625 CodecParms.uBitrate = 0; /* Let Opus decide, based on the number of channels and the input sampling rate. */
626
627 int rc = avRecSinkInit(pThis, &pThis->Sink, &ContainerParms, &CodecParms);
628 if (RT_FAILURE(rc))
629 {
630 LogRel(("VideoRec: Audio recording driver failed to initialize, rc=%Rrc\n", rc));
631 }
632 else
633 LogRel2(("VideoRec: Audio recording driver initialized\n"));
634
635 return rc;
636}
637
638
639/**
640 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCapture}
641 */
642static DECLCALLBACK(int) drvAudioVideoRecStreamCapture(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,
643 void *pvBuf, uint32_t cxBuf, uint32_t *pcxRead)
644{
645 RT_NOREF(pInterface, pStream, pvBuf, cxBuf);
646
647 if (pcxRead)
648 *pcxRead = 0;
649
650 return VINF_SUCCESS;
651}
652
653
654/**
655 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamPlay}
656 */
657static DECLCALLBACK(int) drvAudioVideoRecStreamPlay(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,
658 const void *pvBuf, uint32_t cxBuf, uint32_t *pcxWritten)
659{
660 AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
661 AssertPtrReturn(pStream, VERR_INVALID_POINTER);
662 AssertPtrReturn(pvBuf, VERR_INVALID_POINTER);
663 AssertReturn(cxBuf, VERR_INVALID_PARAMETER);
664 /* pcxWritten is optional. */
665
666 PDRVAUDIOVIDEOREC pThis = PDMIHOSTAUDIO_2_DRVAUDIOVIDEOREC(pInterface);
667 RT_NOREF(pThis);
668 PAVRECSTREAM pStreamAV = (PAVRECSTREAM)pStream;
669
670 int rc = VINF_SUCCESS;
671
672 uint32_t cbWrittenTotal = 0;
673
674 /*
675 * Call the encoder with the data.
676 */
677#ifdef VBOX_WITH_LIBOPUS
678 PAVRECSINK pSink = pStreamAV->pSink;
679 AssertPtr(pSink);
680 PRTCIRCBUF pCircBuf = pStreamAV->pCircBuf;
681 AssertPtr(pCircBuf);
682
683 void *pvCircBuf;
684 size_t cbCircBuf;
685
686 uint32_t cbToWrite = cxBuf;
687
688 /*
689 * Fetch as much as we can into our internal ring buffer.
690 */
691 while ( cbToWrite
692 && RTCircBufFree(pCircBuf))
693 {
694 RTCircBufAcquireWriteBlock(pCircBuf, cbToWrite, &pvCircBuf, &cbCircBuf);
695
696 if (cbCircBuf)
697 {
698 memcpy(pvCircBuf, (uint8_t *)pvBuf + cbWrittenTotal, cbCircBuf),
699 cbWrittenTotal += (uint32_t)cbCircBuf;
700 Assert(cbToWrite >= cbCircBuf);
701 cbToWrite -= (uint32_t)cbCircBuf;
702 }
703
704 RTCircBufReleaseWriteBlock(pCircBuf, cbCircBuf);
705
706 if ( RT_FAILURE(rc)
707 || !cbCircBuf)
708 {
709 break;
710 }
711 }
712
713 /*
714 * Process our internal ring buffer and encode the data.
715 */
716
717 uint8_t abSrc[_64K]; /** @todo Fix! */
718 size_t cbSrc;
719
720 const uint32_t csFrame = pSink->Codec.Parms.PCMProps.uHz / (1000 /* s in ms */ / pSink->Codec.Opus.msFrame);
721 const uint32_t cbFrame = DrvAudioHlpFramesToBytes(csFrame, &pSink->Codec.Parms.PCMProps);
722
723 /* Only encode data if we have data for the given time period (or more). */
724 while (RTCircBufUsed(pCircBuf) >= cbFrame)
725 {
726 cbSrc = 0;
727
728 while (cbSrc < cbFrame)
729 {
730 RTCircBufAcquireReadBlock(pCircBuf, cbFrame - cbSrc, &pvCircBuf, &cbCircBuf);
731
732 if (cbCircBuf)
733 {
734 memcpy(&abSrc[cbSrc], pvCircBuf, cbCircBuf);
735
736 cbSrc += cbCircBuf;
737 Assert(cbSrc <= sizeof(abSrc));
738 }
739
740 RTCircBufReleaseReadBlock(pCircBuf, cbCircBuf);
741
742 if (!cbCircBuf)
743 break;
744 }
745
746# ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA
747 RTFILE fh;
748 RTFileOpen(&fh, VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "DrvAudioVideoRec.pcm",
749 RTFILE_O_OPEN_CREATE | RTFILE_O_APPEND | RTFILE_O_WRITE | RTFILE_O_DENY_NONE);
750 RTFileWrite(fh, abSrc, cbSrc, NULL);
751 RTFileClose(fh);
752# endif
753
754 Assert(cbSrc == cbFrame);
755
756 /*
757 * Opus always encodes PER FRAME, that is, exactly 2.5, 5, 10, 20, 40 or 60 ms of audio data.
758 *
759 * A packet can have up to 120ms worth of audio data.
760 * Anything > 120ms of data will result in a "corrupted package" error message by
761 * by decoding application.
762 */
763 uint8_t abDst[_64K]; /** @todo Fix! */
764 size_t cbDst = sizeof(abDst);
765
766 /* Call the encoder to encode one frame per iteration. */
767 opus_int32 cbWritten = opus_encode(pSink->Codec.Opus.pEnc,
768 (opus_int16 *)abSrc, csFrame, abDst, (opus_int32)cbDst);
769 if (cbWritten > 0)
770 {
771 /* Get overall frames encoded. */
772 const uint32_t cEncFrames = opus_packet_get_nb_frames(abDst, cbWritten);
773
774# ifdef VBOX_WITH_STATISTICS
775 pSink->Codec.STAM.cEncFrames += cEncFrames;
776 pSink->Codec.STAM.msEncTotal += pSink->Codec.Opus.msFrame * cEncFrames;
777
778 LogFunc(("%RU64ms [%RU64 frames]: cbSrc=%zu, cbDst=%zu, cEncFrames=%RU32\n",
779 pSink->Codec.STAM.msEncTotal, pSink->Codec.STAM.cEncFrames, cbSrc, cbDst, cEncFrames));
780# endif
781 Assert((uint32_t)cbWritten <= cbDst);
782 cbDst = RT_MIN((uint32_t)cbWritten, cbDst); /* Update cbDst to actual bytes encoded (written). */
783
784 Assert(cEncFrames == 1); /* At the moment we encode exactly *one* frame per frame. */
785
786 if (pStreamAV->uLastPTSMs == 0)
787 pStreamAV->uLastPTSMs = RTTimeMilliTS() - pSink->tsStartMs;
788
789 const uint64_t uDurationMs = pSink->Codec.Opus.msFrame * cEncFrames;
790 const uint64_t uPTSMs = pStreamAV->uLastPTSMs + uDurationMs;
791
792 pStreamAV->uLastPTSMs += uDurationMs;
793
794 switch (pSink->Con.Parms.enmType)
795 {
796 case AVRECCONTAINERTYPE_MAIN_CONSOLE:
797 {
798 HRESULT hr = pSink->Con.Main.pConsole->i_audioVideoRecSendAudio(abDst, cbDst, uPTSMs);
799 Assert(hr == S_OK);
800 RT_NOREF(hr);
801
802 break;
803 }
804
805 case AVRECCONTAINERTYPE_WEBM:
806 {
807 WebMWriter::BlockData_Opus blockData = { abDst, cbDst, uPTSMs };
808 rc = pSink->Con.WebM.pWebM->WriteBlock(pSink->Con.WebM.uTrack, &blockData, sizeof(blockData));
809 AssertRC(rc);
810
811 break;
812 }
813
814 default:
815 AssertFailedStmt(rc = VERR_NOT_IMPLEMENTED);
816 break;
817 }
818 }
819 else if (cbWritten < 0)
820 {
821 AssertMsgFailed(("Encoding failed: %s\n", opus_strerror(cbWritten)));
822 rc = VERR_INVALID_PARAMETER;
823 }
824
825 if (RT_FAILURE(rc))
826 break;
827 }
828
829 if (pcxWritten)
830 *pcxWritten = cbWrittenTotal;
831#else
832 /* Report back all data as being processed. */
833 if (pcxWritten)
834 *pcxWritten = cxBuf;
835
836 rc = VERR_NOT_SUPPORTED;
837#endif /* VBOX_WITH_LIBOPUS */
838
839 LogFlowFunc(("csReadTotal=%RU32, rc=%Rrc\n", cbWrittenTotal, rc));
840 return rc;
841}
842
843
844/**
845 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetConfig}
846 */
847static DECLCALLBACK(int) drvAudioVideoRecGetConfig(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDCFG pBackendCfg)
848{
849 RT_NOREF(pInterface);
850 AssertPtrReturn(pBackendCfg, VERR_INVALID_POINTER);
851
852 RTStrPrintf2(pBackendCfg->szName, sizeof(pBackendCfg->szName), "Video recording audio driver");
853
854 pBackendCfg->cbStreamOut = sizeof(AVRECSTREAM);
855 pBackendCfg->cbStreamIn = 0;
856 pBackendCfg->cMaxStreamsIn = 0;
857 pBackendCfg->cMaxStreamsOut = UINT32_MAX;
858
859 return VINF_SUCCESS;
860}
861
862
863/**
864 * @interface_method_impl{PDMIHOSTAUDIO,pfnShutdown}
865 */
866static DECLCALLBACK(void) drvAudioVideoRecShutdown(PPDMIHOSTAUDIO pInterface)
867{
868 LogFlowFuncEnter();
869
870 PDRVAUDIOVIDEOREC pThis = PDMIHOSTAUDIO_2_DRVAUDIOVIDEOREC(pInterface);
871
872 avRecSinkShutdown(&pThis->Sink);
873}
874
875
876/**
877 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetStatus}
878 */
879static DECLCALLBACK(PDMAUDIOBACKENDSTS) drvAudioVideoRecGetStatus(PPDMIHOSTAUDIO pInterface, PDMAUDIODIR enmDir)
880{
881 RT_NOREF(enmDir);
882 AssertPtrReturn(pInterface, PDMAUDIOBACKENDSTS_UNKNOWN);
883
884 return PDMAUDIOBACKENDSTS_RUNNING;
885}
886
887
888/**
889 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCreate}
890 */
891static DECLCALLBACK(int) drvAudioVideoRecStreamCreate(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,
892 PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq)
893{
894 AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
895 AssertPtrReturn(pCfgReq, VERR_INVALID_POINTER);
896 AssertPtrReturn(pCfgAcq, VERR_INVALID_POINTER);
897
898 if (pCfgReq->enmDir == PDMAUDIODIR_IN)
899 return VERR_NOT_SUPPORTED;
900
901 AssertPtrReturn(pStream, VERR_INVALID_POINTER);
902
903 PDRVAUDIOVIDEOREC pThis = PDMIHOSTAUDIO_2_DRVAUDIOVIDEOREC(pInterface);
904 PAVRECSTREAM pStreamAV = (PAVRECSTREAM)pStream;
905
906 /* For now we only have one sink, namely the driver's one.
907 * Later each stream could have its own one, to e.g. router different stream to different sinks .*/
908 PAVRECSINK pSink = &pThis->Sink;
909
910 int rc = avRecCreateStreamOut(pThis, pStreamAV, pSink, pCfgReq, pCfgAcq);
911 if (RT_SUCCESS(rc))
912 {
913 pStreamAV->pCfg = DrvAudioHlpStreamCfgDup(pCfgAcq);
914 if (!pStreamAV->pCfg)
915 rc = VERR_NO_MEMORY;
916 }
917
918 return rc;
919}
920
921
922/**
923 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamDestroy}
924 */
925static DECLCALLBACK(int) drvAudioVideoRecStreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
926{
927 AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
928 AssertPtrReturn(pStream, VERR_INVALID_POINTER);
929
930 PDRVAUDIOVIDEOREC pThis = PDMIHOSTAUDIO_2_DRVAUDIOVIDEOREC(pInterface);
931 PAVRECSTREAM pStreamAV = (PAVRECSTREAM)pStream;
932
933 if (!pStreamAV->pCfg) /* Not (yet) configured? Skip. */
934 return VINF_SUCCESS;
935
936 int rc = VINF_SUCCESS;
937
938 if (pStreamAV->pCfg->enmDir == PDMAUDIODIR_OUT)
939 rc = avRecDestroyStreamOut(pThis, pStreamAV);
940
941 if (RT_SUCCESS(rc))
942 {
943 DrvAudioHlpStreamCfgFree(pStreamAV->pCfg);
944 pStreamAV->pCfg = NULL;
945 }
946
947 return rc;
948}
949
950
951/**
952 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamControl}
953 */
954static DECLCALLBACK(int) drvAudioVideoRecStreamControl(PPDMIHOSTAUDIO pInterface,
955 PPDMAUDIOBACKENDSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd)
956{
957 AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
958 AssertPtrReturn(pStream, VERR_INVALID_POINTER);
959
960 PDRVAUDIOVIDEOREC pThis = PDMIHOSTAUDIO_2_DRVAUDIOVIDEOREC(pInterface);
961 PAVRECSTREAM pStreamAV = (PAVRECSTREAM)pStream;
962
963 if (!pStreamAV->pCfg) /* Not (yet) configured? Skip. */
964 return VINF_SUCCESS;
965
966 if (pStreamAV->pCfg->enmDir == PDMAUDIODIR_OUT)
967 return avRecControlStreamOut(pThis, pStreamAV, enmStreamCmd);
968
969 return VINF_SUCCESS;
970}
971
972
973/**
974 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetReadable}
975 */
976static DECLCALLBACK(uint32_t) drvAudioVideoRecStreamGetReadable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
977{
978 RT_NOREF(pInterface, pStream);
979
980 return 0; /* Video capturing does not provide any input. */
981}
982
983
984/**
985 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetWritable}
986 */
987static DECLCALLBACK(uint32_t) drvAudioVideoRecStreamGetWritable(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
988{
989 RT_NOREF(pInterface, pStream);
990
991 return UINT32_MAX;
992}
993
994
995/**
996 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus}
997 */
998static DECLCALLBACK(PDMAUDIOSTREAMSTS) drvAudioVideoRecStreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
999{
1000 RT_NOREF(pInterface, pStream);
1001
1002 return (PDMAUDIOSTREAMSTS_FLAG_INITIALIZED | PDMAUDIOSTREAMSTS_FLAG_ENABLED);
1003}
1004
1005
1006/**
1007 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamIterate}
1008 */
1009static DECLCALLBACK(int) drvAudioVideoRecStreamIterate(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
1010{
1011 AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
1012 AssertPtrReturn(pStream, VERR_INVALID_POINTER);
1013
1014 LogFlowFuncEnter();
1015
1016 /* Nothing to do here for video recording. */
1017 return VINF_SUCCESS;
1018}
1019
1020
1021/**
1022 * @interface_method_impl{PDMIBASE,pfnQueryInterface}
1023 */
1024static DECLCALLBACK(void *) drvAudioVideoRecQueryInterface(PPDMIBASE pInterface, const char *pszIID)
1025{
1026 PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface);
1027 PDRVAUDIOVIDEOREC pThis = PDMINS_2_DATA(pDrvIns, PDRVAUDIOVIDEOREC);
1028
1029 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase);
1030 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIHOSTAUDIO, &pThis->IHostAudio);
1031 return NULL;
1032}
1033
1034
1035AudioVideoRec::AudioVideoRec(Console *pConsole)
1036 : AudioDriver(pConsole)
1037 , mpDrv(NULL)
1038{
1039}
1040
1041
1042AudioVideoRec::~AudioVideoRec(void)
1043{
1044 if (mpDrv)
1045 {
1046 mpDrv->pAudioVideoRec = NULL;
1047 mpDrv = NULL;
1048 }
1049}
1050
1051
1052/**
1053 * @copydoc AudioDriver::configureDriver
1054 */
1055int AudioVideoRec::configureDriver(PCFGMNODE pLunCfg)
1056{
1057 CFGMR3InsertInteger(pLunCfg, "Object", (uintptr_t)mpConsole->i_getAudioVideoRec());
1058 CFGMR3InsertInteger(pLunCfg, "ObjectConsole", (uintptr_t)mpConsole);
1059
1060 return VINF_SUCCESS;
1061}
1062
1063
1064/**
1065 * Construct a audio video recording driver instance.
1066 *
1067 * @copydoc FNPDMDRVCONSTRUCT
1068 */
1069/* static */
1070DECLCALLBACK(int) AudioVideoRec::drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags)
1071{
1072 PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns);
1073 PDRVAUDIOVIDEOREC pThis = PDMINS_2_DATA(pDrvIns, PDRVAUDIOVIDEOREC);
1074 RT_NOREF(fFlags);
1075
1076 LogRel(("Audio: Initializing video recording audio driver\n"));
1077 LogFlowFunc(("fFlags=0x%x\n", fFlags));
1078
1079 AssertMsgReturn(PDMDrvHlpNoAttach(pDrvIns) == VERR_PDM_NO_ATTACHED_DRIVER,
1080 ("Configuration error: Not possible to attach anything to this driver!\n"),
1081 VERR_PDM_DRVINS_NO_ATTACH);
1082
1083 /*
1084 * Init the static parts.
1085 */
1086 pThis->pDrvIns = pDrvIns;
1087 /* IBase */
1088 pDrvIns->IBase.pfnQueryInterface = drvAudioVideoRecQueryInterface;
1089 /* IHostAudio */
1090 PDMAUDIO_IHOSTAUDIO_CALLBACKS(drvAudioVideoRec);
1091
1092 /*
1093 * Get the Console object pointer.
1094 */
1095 void *pvUser;
1096 int rc = CFGMR3QueryPtr(pCfg, "ObjectConsole", &pvUser); /** @todo r=andy Get rid of this hack and use IHostAudio::SetCallback. */
1097 AssertRCReturn(rc, rc);
1098
1099 /* CFGM tree saves the pointer to Console in the Object node of AudioVideoRec. */
1100 pThis->pConsole = (Console *)pvUser;
1101 AssertReturn(!pThis->pConsole.isNull(), VERR_INVALID_POINTER);
1102
1103 /*
1104 * Get the pointer to the audio driver instance.
1105 */
1106 rc = CFGMR3QueryPtr(pCfg, "Object", &pvUser); /** @todo r=andy Get rid of this hack and use IHostAudio::SetCallback. */
1107 AssertRCReturn(rc, rc);
1108
1109 pThis->pAudioVideoRec = (AudioVideoRec *)pvUser;
1110 AssertPtrReturn(pThis->pAudioVideoRec, VERR_INVALID_POINTER);
1111
1112 pThis->pAudioVideoRec->mpDrv = pThis;
1113
1114 /*
1115 * Get the interface for the above driver (DrvAudio) to make mixer/conversion calls.
1116 * Described in CFGM tree.
1117 */
1118 pThis->pDrvAudio = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMIAUDIOCONNECTOR);
1119 AssertMsgReturn(pThis->pDrvAudio, ("Configuration error: No upper interface specified!\n"), VERR_PDM_MISSING_INTERFACE_ABOVE);
1120
1121#ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA
1122 RTFileDelete(VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "DrvAudioVideoRec.webm");
1123 RTFileDelete(VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "DrvAudioVideoRec.pcm");
1124#endif
1125
1126 return VINF_SUCCESS;
1127}
1128
1129
1130/**
1131 * @interface_method_impl{PDMDRVREG,pfnDestruct}
1132 */
1133/* static */
1134DECLCALLBACK(void) AudioVideoRec::drvDestruct(PPDMDRVINS pDrvIns)
1135{
1136 PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns);
1137 PDRVAUDIOVIDEOREC pThis = PDMINS_2_DATA(pDrvIns, PDRVAUDIOVIDEOREC);
1138 LogFlowFuncEnter();
1139
1140 /*
1141 * If the AudioVideoRec object is still alive, we must clear it's reference to
1142 * us since we'll be invalid when we return from this method.
1143 */
1144 if (pThis->pAudioVideoRec)
1145 {
1146 pThis->pAudioVideoRec->mpDrv = NULL;
1147 pThis->pAudioVideoRec = NULL;
1148 }
1149}
1150
1151
1152/**
1153 * @interface_method_impl{PDMDRVREG,pfnAttach}
1154 */
1155/* static */
1156DECLCALLBACK(int) AudioVideoRec::drvAttach(PPDMDRVINS pDrvIns, uint32_t fFlags)
1157{
1158 RT_NOREF(pDrvIns, fFlags);
1159
1160 LogFlowFuncEnter();
1161
1162 return VINF_SUCCESS;
1163}
1164
1165/**
1166 * @interface_method_impl{PDMDRVREG,pfnDetach}
1167 */
1168/* static */
1169DECLCALLBACK(void) AudioVideoRec::drvDetach(PPDMDRVINS pDrvIns, uint32_t fFlags)
1170{
1171 RT_NOREF(pDrvIns, fFlags);
1172
1173 LogFlowFuncEnter();
1174}
1175
1176/**
1177 * Video recording audio driver registration record.
1178 */
1179const PDMDRVREG AudioVideoRec::DrvReg =
1180{
1181 PDM_DRVREG_VERSION,
1182 /* szName */
1183 "AudioVideoRec",
1184 /* szRCMod */
1185 "",
1186 /* szR0Mod */
1187 "",
1188 /* pszDescription */
1189 "Audio driver for video recording",
1190 /* fFlags */
1191 PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT,
1192 /* fClass. */
1193 PDM_DRVREG_CLASS_AUDIO,
1194 /* cMaxInstances */
1195 ~0U,
1196 /* cbInstance */
1197 sizeof(DRVAUDIOVIDEOREC),
1198 /* pfnConstruct */
1199 AudioVideoRec::drvConstruct,
1200 /* pfnDestruct */
1201 AudioVideoRec::drvDestruct,
1202 /* pfnRelocate */
1203 NULL,
1204 /* pfnIOCtl */
1205 NULL,
1206 /* pfnPowerOn */
1207 NULL,
1208 /* pfnReset */
1209 NULL,
1210 /* pfnSuspend */
1211 NULL,
1212 /* pfnResume */
1213 NULL,
1214 /* pfnAttach */
1215 AudioVideoRec::drvAttach,
1216 /* pfnDetach */
1217 AudioVideoRec::drvDetach,
1218 /* pfnPowerOff */
1219 NULL,
1220 /* pfnSoftReset */
1221 NULL,
1222 /* u32EndVersion */
1223 PDM_DRVREG_VERSION
1224};
1225
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette