BltMediaPort.h

Go to the documentation of this file.
00001 /*****************************************************************
00002 |
00003 |   BlueTune - Media Port Interface
00004 |
00005 |   (c) 2002-2006 Gilles Boccon-Gibod
00006 |   Author: Gilles Boccon-Gibod (bok@bok.net)
00007 |
00008  ****************************************************************/
00013 #ifndef _BLT_MEDIA_PORT_H_
00014 #define _BLT_MEDIA_PORT_H_
00015 
00016 /*----------------------------------------------------------------------
00017 |   includes
00018 +---------------------------------------------------------------------*/
00019 #include "Atomix.h"
00020 #include "BltDefs.h"
00021 #include "BltTypes.h"
00022 #include "BltErrors.h"
00023 #include "BltMedia.h"
00024 
00025 /*----------------------------------------------------------------------
00026 |   error codes
00027 +---------------------------------------------------------------------*/
00028 #define BLT_ERROR_NO_SUCH_PORT       (BLT_ERROR_BASE_MEDIA_PORT - 0)
00029 #define BLT_ERROR_PORT_HAS_NO_DATA   (BLT_ERROR_BASE_MEDIA_PORT - 1)
00030 #define BLT_ERROR_PORT_HAS_NO_STREAM (BLT_ERROR_BASE_MEDIA_PORT - 2)
00031 
00032 /*----------------------------------------------------------------------
00033 |   types
00034 +---------------------------------------------------------------------*/
00035 typedef enum {
00036     BLT_MEDIA_PORT_PROTOCOL_ANY,
00037     BLT_MEDIA_PORT_PROTOCOL_NONE,
00038     BLT_MEDIA_PORT_PROTOCOL_PACKET,
00039     BLT_MEDIA_PORT_PROTOCOL_STREAM_PUSH,
00040     BLT_MEDIA_PORT_PROTOCOL_STREAM_PULL
00041 } BLT_MediaPortProtocol;
00042 
00043 typedef enum {
00044     BLT_MEDIA_PORT_DIRECTION_NONE,
00045     BLT_MEDIA_PORT_DIRECTION_IN,
00046     BLT_MEDIA_PORT_DIRECTION_OUT
00047 } BLT_MediaPortDirection;
00048 
00049 typedef struct {
00050     BLT_MediaPortProtocol protocol;
00051     const BLT_MediaType*  media_type;
00052 } BLT_MediaPortInterfaceSpec;
00053 
00054 /*----------------------------------------------------------------------
00055 |   BLT_MediaPort Interface
00056 +---------------------------------------------------------------------*/
00057 ATX_DECLARE_INTERFACE(BLT_MediaPort)
00058 ATX_BEGIN_INTERFACE_DEFINITION(BLT_MediaPort)
00059     BLT_Result (*GetName)(BLT_MediaPort*  self, BLT_CString* name);
00060     BLT_Result (*GetProtocol)(BLT_MediaPort*         self, 
00061                               BLT_MediaPortProtocol* protocol);
00062     BLT_Result (*GetDirection)(BLT_MediaPort*          self, 
00063                                BLT_MediaPortDirection* direction);
00064     BLT_Result (*QueryMediaType)(BLT_MediaPort*        self,
00065                                  BLT_Ordinal           index,
00066                                  const BLT_MediaType** media_type);
00067 ATX_END_INTERFACE_DEFINITION
00068 
00069 /*----------------------------------------------------------------------
00070 |   convenience macros
00071 +---------------------------------------------------------------------*/
00072 #define BLT_MediaPort_GetName(object, name)\
00073 ATX_INTERFACE(object)->GetProtocol(object, name)
00074 
00075 #define BLT_MediaPort_GetProtocol(object, protocol)\
00076 ATX_INTERFACE(object)->GetProtocol(object, protocol)
00077 
00078 #define BLT_MediaPort_GetDirection(object, direction)\
00079 ATX_INTERFACE(object)->GetDirection(object, direction)
00080 
00081 #define BLT_MediaPort_QueryMediaType(object, index, media_type)\
00082 ATX_INTERFACE(object)->QueryMediaType(object, index, media_type)
00083 
00084 /*----------------------------------------------------------------------
00085 |   templates
00086 +---------------------------------------------------------------------*/
00087 #define BLT_MEDIA_PORT_IMPLEMENT_SIMPLE_TEMPLATE(port, n, proto, dir)   \
00088 BLT_METHOD port##_GetName(BLT_MediaPort* self, BLT_CString* name)       \
00089 {                                                                       \
00090     BLT_COMPILER_UNUSED(self);                                          \
00091     *name = (n);                                                        \
00092     return BLT_SUCCESS;                                                 \
00093 }                                                                       \
00094 BLT_METHOD port##_GetProtocol(BLT_MediaPort*         self,              \
00095                               BLT_MediaPortProtocol* protocol)          \
00096 {                                                                       \
00097     BLT_COMPILER_UNUSED(self);                                          \
00098     *protocol = BLT_MEDIA_PORT_PROTOCOL_##proto;                        \
00099     return BLT_SUCCESS;                                                 \
00100 }                                                                       \
00101 BLT_METHOD port##_GetDirection(BLT_MediaPort*          self,            \
00102                                BLT_MediaPortDirection* direction)       \
00103 {                                                                       \
00104     BLT_COMPILER_UNUSED(self);                                          \
00105     *direction = BLT_MEDIA_PORT_DIRECTION_##dir;                        \
00106     return BLT_SUCCESS;                                                 \
00107 }
00108 
00109 
00110 /*----------------------------------------------------------------------
00111 |   functions
00112 +---------------------------------------------------------------------*/
00113 BLT_Result 
00114 BLT_MediaPort_DefaultQueryMediaType(BLT_MediaPort*         self,
00115                                     BLT_Ordinal            index,
00116                                     const BLT_MediaType**  media_type);
00117 
00118 #endif /* _BLT_MEDIA_PORT_H_ */