BMediaRecorder: fix a few issues, fix style, remove unused SoundUtils
* Use the preferred time source (GetTimeSource) for the node * Fix node releasing when creating the connection fails * Add virtual slots and padding * Refactor _Connect method
This commit is contained in:
@@ -6,16 +6,31 @@
|
||||
#define _MEDIA_RECORDER_H
|
||||
|
||||
|
||||
#include <MediaDefs.h>
|
||||
#include <MediaNode.h>
|
||||
#include <TimeSource.h>
|
||||
|
||||
#include "MediaRecorderNode.h"
|
||||
#include "SoundUtils.h"
|
||||
|
||||
|
||||
namespace BPrivate { namespace media {
|
||||
|
||||
|
||||
class BMediaRecorderNode;
|
||||
|
||||
class BMediaRecorder {
|
||||
public:
|
||||
enum notification {
|
||||
B_WILL_START = 1, // performance_time
|
||||
B_WILL_STOP, // performance_time immediate
|
||||
B_WILL_SEEK, // performance_time media_time
|
||||
B_WILL_TIMEWARP, // real_time performance_time
|
||||
};
|
||||
|
||||
typedef void (*ProcessFunc)(void* cookie,
|
||||
bigtime_t timestamp, void* data,
|
||||
size_t size, const media_format& format);
|
||||
|
||||
typedef void (*NotifyFunc)(void* cookie,
|
||||
notification what, ...);
|
||||
|
||||
public:
|
||||
BMediaRecorder(const char* name,
|
||||
media_type type
|
||||
@@ -25,14 +40,6 @@ public:
|
||||
|
||||
status_t InitCheck() const;
|
||||
|
||||
typedef void (*ProcessFunc)(void* cookie,
|
||||
bigtime_t timestamp, void* data,
|
||||
size_t datasize,
|
||||
const media_format& format);
|
||||
|
||||
typedef void (*NotifyFunc)(void* cookie,
|
||||
int32 code, ...);
|
||||
|
||||
status_t SetHooks(ProcessFunc recordFunc = NULL,
|
||||
NotifyFunc notifyFunc = NULL,
|
||||
void* cookie = NULL);
|
||||
@@ -43,17 +50,14 @@ public:
|
||||
virtual status_t Start(bool force = false);
|
||||
virtual status_t Stop(bool force = false);
|
||||
|
||||
virtual status_t Connect(const media_format& format,
|
||||
uint32 flags = 0);
|
||||
virtual status_t Connect(const media_format& format);
|
||||
|
||||
virtual status_t Connect(const dormant_node_info& dormantInfo,
|
||||
const media_format* format = NULL,
|
||||
uint32 flags = 0);
|
||||
const media_format& format);
|
||||
|
||||
virtual status_t Connect(const media_node& node,
|
||||
const media_output* useOutput = NULL,
|
||||
const media_format* format = NULL,
|
||||
uint32 flags = 0);
|
||||
const media_output* output = NULL,
|
||||
const media_format* format = NULL);
|
||||
|
||||
virtual status_t Disconnect();
|
||||
|
||||
@@ -67,37 +71,42 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
virtual void BufferReceived(void* buffer,
|
||||
size_t size,
|
||||
virtual void BufferReceived(void* buffer, size_t size,
|
||||
const media_header& header);
|
||||
private:
|
||||
|
||||
status_t _Connect(
|
||||
const media_format* format,
|
||||
uint32 flags,
|
||||
const dormant_node_info* dormantNode,
|
||||
const media_node* mediaNode,
|
||||
const media_output* output);
|
||||
status_t _Connect(const media_node& mediaNode,
|
||||
const media_output* output,
|
||||
const media_format& format);
|
||||
|
||||
status_t fInitErr;
|
||||
virtual void _ReservedMediaRecorder0();
|
||||
virtual void _ReservedMediaRecorder1();
|
||||
virtual void _ReservedMediaRecorder2();
|
||||
virtual void _ReservedMediaRecorder3();
|
||||
virtual void _ReservedMediaRecorder4();
|
||||
virtual void _ReservedMediaRecorder5();
|
||||
virtual void _ReservedMediaRecorder6();
|
||||
virtual void _ReservedMediaRecorder7();
|
||||
|
||||
bool fConnected;
|
||||
bool fRunning;
|
||||
status_t fInitErr;
|
||||
|
||||
BTimeSource* fTimeSource;
|
||||
bool fConnected;
|
||||
bool fRunning;
|
||||
bool fReleaseOutputNode;
|
||||
|
||||
ProcessFunc fRecordHook;
|
||||
NotifyFunc fNotifyHook;
|
||||
ProcessFunc fRecordHook;
|
||||
NotifyFunc fNotifyHook;
|
||||
|
||||
media_node fOutputNode;
|
||||
media_output fOutput;
|
||||
media_node fOutputNode;
|
||||
media_output fOutput;
|
||||
|
||||
BMediaRecorderNode* fNode;
|
||||
media_input fInput;
|
||||
BMediaRecorderNode* fNode;
|
||||
media_input fInput;
|
||||
|
||||
void* fBufferCookie;
|
||||
void* fBufferCookie;
|
||||
uint32 fPadding[32];
|
||||
|
||||
friend class BMediaRecorderNode;
|
||||
friend class BMediaRecorderNode;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 1999, Be Incorporated
|
||||
* Copyright 2014, Dario Casalinuovo
|
||||
* Copyright 1999, Be Incorporated
|
||||
* All Rights Reserved.
|
||||
* This file may be used under the terms of the Be Sample Code License.
|
||||
*/
|
||||
@@ -76,27 +76,23 @@ protected:
|
||||
virtual void BufferReceived(BBuffer* buffer);
|
||||
|
||||
virtual void ProducerDataStatus(
|
||||
const media_destination& forWhom,
|
||||
const media_destination& destination,
|
||||
int32 status,
|
||||
bigtime_t performanceTime);
|
||||
|
||||
virtual status_t GetLatencyFor(
|
||||
const media_destination& forWhom,
|
||||
bigtime_t* outLatency,
|
||||
media_node_id* outTimesource);
|
||||
virtual status_t GetLatencyFor(const media_destination& destination,
|
||||
bigtime_t* outLatency,
|
||||
media_node_id* outTimesource);
|
||||
|
||||
virtual status_t Connected(
|
||||
const media_source& producer,
|
||||
virtual status_t Connected(const media_source& producer,
|
||||
const media_destination& where,
|
||||
const media_format& withFormat,
|
||||
const media_format& format,
|
||||
media_input* outInput);
|
||||
|
||||
virtual void Disconnected(
|
||||
const media_source& producer,
|
||||
virtual void Disconnected(const media_source& producer,
|
||||
const media_destination& where);
|
||||
|
||||
virtual status_t FormatChanged(
|
||||
const media_source& producer,
|
||||
virtual status_t FormatChanged(const media_source& producer,
|
||||
const media_destination& consumer,
|
||||
int32 tag,
|
||||
const media_format& format);
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
/*******************************************************************************
|
||||
/
|
||||
/ File: SoundUtils.h
|
||||
/
|
||||
/ Description: Utility functions for handling audio data.
|
||||
/
|
||||
/ Copyright 1998-1999, Be Incorporated, All Rights Reserved
|
||||
/
|
||||
*******************************************************************************/
|
||||
|
||||
#if ! defined( _SoundUtils_h )
|
||||
#define _SoundUtils_h
|
||||
|
||||
#include <MediaDefs.h>
|
||||
|
||||
// Simple helper functions that come in handy when doing
|
||||
// buffer calculations.
|
||||
double us_to_s(bigtime_t usecs);
|
||||
bigtime_t s_to_us(double secs);
|
||||
|
||||
int bytes_per_frame(const media_raw_audio_format & format);
|
||||
int frames_per_buffer(const media_raw_audio_format & format);
|
||||
bigtime_t buffer_duration(const media_raw_audio_format & format);
|
||||
bigtime_t frames_duration(const media_raw_audio_format & format,
|
||||
int64 num_frames);
|
||||
int64 frames_for_duration(const media_raw_audio_format & format,
|
||||
bigtime_t duration);
|
||||
int buffers_for_duration(const media_raw_audio_format & format,
|
||||
bigtime_t duration);
|
||||
|
||||
// This is a common hook function interface for
|
||||
// SoundConsumer and SoundProducer to use.
|
||||
typedef void (*SoundProcessFunc)(void * cookie,
|
||||
bigtime_t timestamp, void * data, size_t datasize,
|
||||
const media_raw_audio_format & format);
|
||||
typedef void (*SoundNotifyFunc)(void * cookie,
|
||||
int32 code, ...);
|
||||
|
||||
// These are special codes that we use in the Notify
|
||||
// function hook.
|
||||
enum {
|
||||
B_WILL_START = 1, // performance_time
|
||||
B_WILL_STOP, // performance_time immediate
|
||||
B_WILL_SEEK, // performance_time media_time
|
||||
B_WILL_TIMEWARP, // real_time performance_time
|
||||
B_CONNECTED, // name (char*)
|
||||
B_DISCONNECTED, //
|
||||
B_FORMAT_CHANGED, // media_raw_audio_format*
|
||||
B_NODE_DIES, // node will die!
|
||||
B_HOOKS_CHANGED, //
|
||||
B_OP_TIMED_OUT, // timeout that expired -- Consumer only
|
||||
B_PRODUCER_DATA_STATUS, // status performance_time -- Consumer only
|
||||
B_LATE_NOTICE // how_much performance_time -- Producer only
|
||||
};
|
||||
|
||||
#endif /* _SoundUtils_h */
|
||||
Reference in New Issue
Block a user