It is accomplished ...

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
ejakowatz
2002-07-09 12:24:59 +00:00
commit 52a3801208
2025 changed files with 472889 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
#ifndef _CHANNEL_MIXER_
#define _CHANNEL_MIXER_
/***********************************************************************
* AUTHOR: Marcus Overhagen
* FILE: ChannelMixer.h
* DESCR: Converts mono into stereo
* stereo into mono (this one isn't very good)
* (multiple channel support should be added in the future)
***********************************************************************/
namespace MediaKitPrivate {
class ChannelMixer
{
public:
static status_t
mix(void *dest, int dest_chan_count,
const void *source, int source_chan_count,
int framecount, uint32 format);
static status_t
mix_2_to_1(void *dest, const void *source, int framecount, uint32 format);
static status_t
mix_1_to_2(void *dest, const void *source, int framecount, uint32 format);
};
} //namespace MediaKitPrivate
#endif
+42
View File
@@ -0,0 +1,42 @@
// this header is similar to functions found in libmedia.so
// and the media_kit decoder add-ons
// we will use it as basic information, but are not trying to
// create a binary compatible interface
// this API will totally change, as we are creating our own API
#include <MediaDefs.h>
#include <MediaFormats.h>
namespace media_kit_private {
class Decoder
{
public:
virtual ~Decoder(void); /* this needs to be virtual */
Decoder(void);
/* not sure if all three need to be virtual */
virtual status_t SetTrack(BMediaTrack *track);
/* what does this one do? strange parameters */
virtual status_t Reset(long, long long, long long *, long long, long long *);
virtual status_t GetNextChunk(void const **chunkData, size_t *chunkSize,
media_header *mh, media_decode_info *mdi);
virtual status_t Decode(void *out_buffer, int64 *out_frameCount,
media_header *out_mh, media_decode_info *info) = 0;
virtual status_t Format(media_format *) = 0;
virtual status_t Sniff(media_format const *, void const *in_buffer, unsigned long in_buffersize) = 0;
virtual status_t GetCodecInfo(media_codec_info *out_mci) const = 0;
private:
virtual status_t Perform(long, void *);
//virtual function and data stuffing will be done later
};
}; // namespace media_kit_private
extern "C" status_t register_decoder();
extern "C" BPrivate::Decoder * instantiate_decoder();
+44
View File
@@ -0,0 +1,44 @@
// this header is similar to functions found in libmedia.so
// and the media_kit encoder add-ons
// we will use it as basic information, but are not trying to
// create a binary compatible interface
// this API will totally change, as we are creating our own API
namespace media_kit_private {
class Encoder
{
public:
virtual ~Encoder(void); /* this needs to be virtual */
Encoder(void);
/* not sure if all these need to be virtual */
virtual status_t Flush(void);
virtual status_t StartEncoder(void);
virtual status_t SetEncodeParameters(encode_parameters *);
virtual status_t GetEncodeParameters(encode_parameters *) const;
virtual status_t GetParameterView(void);
virtual status_t SetParameterValue(long, void const *, unsigned long);
virtual status_t GetParameterValue(long, void *, unsigned long *);
virtual status_t WriteChunk(void const *, unsigned long, media_encode_info *);
virtual status_t AddTrackInfo(unsigned long, char const *, unsigned long);
virtual status_t AddCopyright(char const *);
virtual status_t Web(void);
virtual status_t AttachedToTrack(void);
virtual status_t SetTrack(BMediaTrack *);
virtual status_t GetCodecInfo(media_codec_info *) const = 0;
virtual status_t Encode(void const *, long long, media_encode_info *) = 0;
virtual status_t SetFormat(media_file_format *, media_format *, media_format *) = 0;
private:
virtual status_t Perform(long, void *);
//virtual function and data stuffing will be done later
};
}; // namespace media_kit_private
extern "C" status_t register_encoder();
extern "C" BPrivate::Encoder *instantiate_nth_encoder();
extern "C" BPrivate::Encoder *instantiate_encoder();
+45
View File
@@ -0,0 +1,45 @@
// this header is similar to functions found in libmedia.so
// and the media_kit extractor add-ons
// we will use it as basic information, but are not trying to
// create a binary compatible interface
// this API will totally change, as we are creating our own API
namespace media_kit_private {
class Extractor
{
public:
Extractor(void);
virtual ~Extractor(void);
virtual status_t Copyright(void);
virtual status_t Extractor(void);
virtual status_t Perform(long, void *);
virtual status_t SniffFormat(media_format const *, long *, long *);
virtual status_t Source(void) const;
virtual status_t find_stream_extractor(long *, media_format *, BPrivate::Extractor *, long, long *, long *);
virtual status_t Sniff(long *, long *) = 0;
virtual status_t GetDuration(long, long long *) = 0;
virtual status_t SplitNext(long, void *, long long *, char *, long *, char **, long *, media_header *) = 0;
virtual status_t Seek(long, void *, long, long, long long *, long long *, long long *, char *, long *, bool *) = 0;
virtual status_t FreeCookie(long, void *) = 0;
virtual status_t AllocateCookie(long, void **) = 0;
virtual status_t CountFrames(long, long long *) = 0;
virtual status_t TrackInfo(long, media_format *, void **, long *) = 0;
virtual status_t GetFileFormatInfo(media_file_format *) = 0;
private:
virtual status_t Perform(long, void *);
//virtual function and data stuffing will be done later
};
}; // namespace media_kit_private
extern "C" {
status_t instantiate_extractor();
}
+37
View File
@@ -0,0 +1,37 @@
/***********************************************************************
* Copyright (c) 2002 Marcus Overhagen. All Rights Reserved.
* This file may be used under the terms of the OpenBeOS License.
*
* A pool of kernel ports
***********************************************************************/
#ifndef _POOL_PORT_H_
#define _POOL_PORT_H_
class PortPool
{
public:
PortPool();
~PortPool();
port_id GetPort();
void PutPort(port_id port);
private:
void Lock();
void Unlock();
struct PortInfo
{
port_id port;
bool used;
};
PortInfo * pool;
int count;
int maxcount;
int32 locker_atom;
sem_id locker_sem;
};
extern PortPool *_PortPool;
#endif
+53
View File
@@ -0,0 +1,53 @@
#ifndef _SAMPLE_CONVERTER_
#define _SAMPLE_CONVERTER_
/***********************************************************************
* AUTHOR: Marcus Overhagen
* FILE: SampleConverter.h
* DESCR: Converts between different sample formats:
* media_raw_audio_format::B_AUDIO_FLOAT
* media_raw_audio_format::B_AUDIO_INT
* media_raw_audio_format::B_AUDIO_SHORT
* media_raw_audio_format::B_AUDIO_CHAR
* media_raw_audio_format::B_AUDIO_UCHAR
***********************************************************************/
namespace MediaKitPrivate {
class SampleConverter
{
public:
static status_t
convert(void *dest, uint32 dest_format,
const void *source, uint32 source_format,
int samplecount);
static void convert(uint8 *dest, const float *source, int samplecount);
static void convert(uint8 *dest, const int32 *source, int samplecount);
static void convert(uint8 *dest, const int16 *source, int samplecount);
static void convert(uint8 *dest, const int8 *source, int samplecount);
static void convert(int8 *dest, const float *source, int samplecount);
static void convert(int8 *dest, const int32 *source, int samplecount);
static void convert(int8 *dest, const int16 *source, int samplecount);
static void convert(int8 *dest, const uint8 *source, int samplecount);
static void convert(int16 *dest, const float *source, int samplecount);
static void convert(int16 *dest, const int32 *source, int samplecount);
static void convert(int16 *dest, const int8 *source, int samplecount);
static void convert(int16 *dest, const uint8 *source, int samplecount);
static void convert(int32 *dest, const float *source, int samplecount);
static void convert(int32 *dest, const int16 *source, int samplecount);
static void convert(int32 *dest, const int8 *source, int samplecount);
static void convert(int32 *dest, const uint8 *source, int samplecount);
static void convert(float *dest, const int32 *source, int samplecount);
static void convert(float *dest, const int16 *source, int samplecount);
static void convert(float *dest, const int8 *source, int samplecount);
static void convert(float *dest, const uint8 *source, int samplecount);
};
} //namespace MediaKitPrivate
#endif
@@ -0,0 +1,29 @@
#ifndef _SAMPLINGRATE_CONVERTER_
#define _SAMPLINGRATE_CONVERTER_
/***********************************************************************
* AUTHOR: Marcus Overhagen
* FILE: SamplingrateConverter.cpp
* DESCR: Converts between different sampling rates
* This is really bad code, as there are much better algorithms
* than the simple duplicating or dropping of samples.
* Also, the implementation isn't very nice.
* Feel free to send me better versions to [email protected]
***********************************************************************/
namespace MediaKitPrivate {
class SamplingrateConverter
{
public:
static status_t
convert(void *dest, int destframecount,
const void *src, int srcframecount,
uint32 format,
int channel_count);
};
} //namespace MediaKitPrivate
#endif
+51
View File
@@ -0,0 +1,51 @@
/***********************************************************************
* Copyright (c) 2002 Marcus Overhagen. All Rights Reserved.
* This file may be used under the terms of the OpenBeOS License.
*
* Used for BBufferGroup and BBuffer management across teams
***********************************************************************/
#ifndef _SHARED_BUFFER_LIST_H_
#define _SHARED_BUFFER_LIST_H_
// created in the media server, cloned into
// each BBufferGroup (visible in all address spaces / teams)
struct _shared_buffer_list
{
struct _shared_buffer_info
{
media_buffer_id id;
BBuffer * buffer;
bool reclaimed;
// the reclaim_sem belonging to the BBufferGroup of this BBuffer
// also used as a unique identifier of the group
sem_id reclaim_sem;
};
enum { MAX_BUFFER = 666 }; // this fixed limit is probably very evil
sem_id locker_sem;
int32 locker_atom;
// always only the first "buffercount" entries in the "info" array are used
int32 buffercount;
_shared_buffer_info info[MAX_BUFFER];
status_t AddBuffer(sem_id group_reclaim_sem, BBuffer *buffer);
status_t RequestBuffer(sem_id group_reclaim_sem, int32 buffers_in_group, size_t size, media_buffer_id wantID, BBuffer **buffer, bigtime_t timeout);
status_t GetBufferList(sem_id group_reclaim_sem, int32 buf_count, BBuffer **out_buffers);
status_t RecycleBuffer(BBuffer *buffer);
status_t Init();
static _shared_buffer_list *Clone(area_id id = -1);
void Terminate(sem_id group_reclaim_sem);
void Unmap();
status_t Lock();
status_t Unlock();
// used by RequestBuffer, call this one with the list locked!
void RequestBufferInOtherGroups(sem_id group_reclaim_sem, media_buffer_id id);
};
#endif
+40
View File
@@ -0,0 +1,40 @@
template<class value> class List
{
public:
List() : count(0) {}
void Insert(const value &v)
{
value temp;
if (count == MAXENT) debugger("template List out of memory");
list[count] = v;
count++;
}
// you can't Remove() while iterating through the list using GetAt()
bool GetAt(int32 index, value *v)
{
if (index < 0 || index >= count)
return false;
*v = list[index];
return true;
}
// you can't Remove() while iterating through the map using GetAt()
bool Remove(int32 index)
{
if (index < 0 || index >= count)
return false;
count--;
if (count > 0)
list[index] = list[count];
return true;
}
private:
enum { MAXENT = 64 };
value list[MAXENT];
int count;
};
+60
View File
@@ -0,0 +1,60 @@
template<class key, class value> class Map
{
public:
Map() : count(0) {}
void Insert(const key &k, const value &v)
{
value temp;
if (count == MAXENT) debugger("template Map out of memory");
if (Get(k, &temp)) debugger("template Map inserting duplicate key");
list[count].k = k;
list[count].v = v;
count++;
}
bool Get(const key &k, value *v)
{
for (int i = 0; i < count; i++)
if (list[i].k == k) {
*v = list[i].v;
return true;
}
return false;
}
// you can't Remove() while iterating through the map using GetAt()
bool GetAt(int32 index, value *v)
{
if (index < 0 || index >= count)
return false;
*v = list[index].v;
return true;
}
// you can't Remove() while iterating through the map using GetAt()
bool Remove(const key &k)
{
for (int i = 0; i < count; i++)
if (list[i].k == k) {
count--;
if (count > 0) {
list[i].v = list[count].v;
list[i].k = list[count].k;
}
return true;
}
return false;
}
private:
enum { MAXENT = 64 };
struct ent {
key k;
value v;
};
ent list[MAXENT];
int count;
};
+17
View File
@@ -0,0 +1,17 @@
#ifndef _VOLUME_CONTROL_
#define _VOLUME_CONTROL_
/***********************************************************************
* AUTHOR: Marcus Overhagen
* FILE: VolumeControl.h
* DESCR: transitional private volume control functions
***********************************************************************/
namespace MediaKitPrivate {
status_t GetMasterVolume(float *left, float *right);
status_t SetMasterVolume(float left, float right);
} //namespace MediaKitPrivate
#endif
+38
View File
@@ -0,0 +1,38 @@
// this header is similar to functions found in libmedia.so
// and the media_kit writer add-ons
// we will use it as basic information, but are not trying to
// create a binary compatible interface
// this API will totally change, as we are creating our own API
namespace media_kit_private {
class Writer
{
public:
Writer(void)
virtual ~Writer(void);
virtual status_t SetWriteBufferSize(unsigned long);
virtual status_t SetSource(BDataIO *) = 0;
virtual status_t AddTrack(BMediaTrack *) = 0;
virtual status_t CommitHeader(void) = 0;
virtual status_t WriteData(long, media_type, void const *, unsigned long, media_encode_info *) = 0;
virtual status_t CloseFile(void) = 0;
virtual status_t AddTrackInfo(long, unsigned long, char const *, unsigned long) = 0;
virtual status_t AddCopyright(char const *) = 0;
virtual status_t AddChunk(long, char const *, unsigned long) = 0;
private:
virtual status_t Perform(long, void *);
//virtual function and data stuffing will be done later
};
}; // namespace media_kit_private
extern "C" {
status_t accepts_format();
status_t get_mediawriter_info();
status_t instantiate_mediawriter();
};
+40
View File
@@ -0,0 +1,40 @@
#include <stdio.h>
#ifndef NDEBUG
#ifndef DEBUG
#define DEBUG 2
#endif
#if DEBUG >= 1
#define UNIMPLEMENTED() printf("libmedia.so: UNIMPLEMENTED %s\n",__PRETTY_FUNCTION__)
#else
#define UNIMPLEMENTED() ((void)0)
#endif
#if DEBUG >= 2
#define BROKEN() printf("libmedia.so: BROKEN %s\n",__PRETTY_FUNCTION__)
#else
#define BROKEN() ((void)0)
#endif
#if DEBUG >= 3
#define CALLED() printf("libmedia.so: CALLED %s\n",__PRETTY_FUNCTION__)
#else
#define CALLED() ((void)0)
#endif
#undef TRACE
#define TRACE \
printf
#else
#define UNIMPLEMENTED() ((void)0)
#define BROKEN() ((void)0)
#define CALLED() ((void)0)
#define TRACE \
if (1) {} else printf
#endif