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
+547
View File
@@ -0,0 +1,547 @@
/******************************************************************************
/
/ File: BeBuild.h
/
/ Description: Import/export macros
/
/ Copyright 1993-98, Be Incorporated
/
*******************************************************************************/
#ifndef _BE_BUILD_H
#define _BE_BUILD_H
#define B_BEOS_VERSION_4 0x0400
#define B_BEOS_VERSION_4_5 0x0450
#define B_BEOS_VERSION_5 0x0500
#define B_BEOS_VERSION B_BEOS_VERSION_5
#define B_BEOS_VERSION_MAUI B_BEOS_VERSION_5
#if defined(__powerc) || defined(powerc)
#define _PR2_COMPATIBLE_ 1
#define _PR3_COMPATIBLE_ 1
#define _R4_COMPATIBLE_ 1
#define _R4_5_COMPATIBLE_ 1
#else
#define _PR2_COMPATIBLE_ 0
#define _PR3_COMPATIBLE_ 0
#define _R4_COMPATIBLE_ 1
#define _R4_5_COMPATIBLE_ 1
#endif
#if __MWERKS__
#define _UNUSED(x)
#define _PACKED
#endif
#if __GNUC__
#define _UNUSED(x) x
#define _PACKED __attribute__((packed))
#endif
#if _STATIC_LINKING
#define _EXPORT
#define _IMPORT
#define _IMPEXP_KERNEL
#define _IMPEXP_GL
#define _IMPEXP_ROOT
#define _IMPEXP_NET
#define _IMPEXP_NETDEV
#define _IMPEXP_ATALK
#define _IMPEXP_BE
#define _IMPEXP_TRACKER
#define _IMPEXP_MAIL
#define _IMPEXP_DEVICE
#define _IMPEXP_MEDIA
#define _IMPEXP_MIDI
#define _IMPEXP_MIDI2
#define _IMPEXP_GAME
#define _IMPEXP_GSOUND
#define _IMPEXP_TRANSLATION
#define _IMPEXP_TEXTENCODING
#define _IMPEXP_INPUT
#else
#if __INTEL__
#define _EXPORT __declspec(dllexport)
#define _IMPORT __declspec(dllimport)
#if _BUILDING_kernel
#define _IMPEXP_KERNEL __declspec(dllexport)
#else
#define _IMPEXP_KERNEL __declspec(dllimport)
#endif
#if _BUILDING_root
#define _IMPEXP_ROOT __declspec(dllexport)
#else
#define _IMPEXP_ROOT __declspec(dllimport)
#endif
#if _BUILDING_net
#define _IMPEXP_NET __declspec(dllexport)
#else
#define _IMPEXP_NET __declspec(dllimport)
#endif
#if _BUILDING_netdev
#define _IMPEXP_NETDEV __declspec(dllexport)
#else
#define _IMPEXP_NETDEV __declspec(dllimport)
#endif
#if _BUILDING_atalk
#define _IMPEXP_ATALK __declspec(dllexport)
#else
#define _IMPEXP_ATALK __declspec(dllimport)
#endif
#if _BUILDING_be
#define _IMPEXP_BE __declspec(dllexport)
#else
#define _IMPEXP_BE __declspec(dllimport)
#endif
#if _BUILDING_gl
#define _IMPEXP_GL __declspec(dllexport)
#else
#define _IMPEXP_GL __declspec(dllimport)
#endif
#if _BUILDING_tracker
#define _IMPEXP_TRACKER __declspec(dllexport)
#else
#define _IMPEXP_TRACKER __declspec(dllimport)
#endif
#if _BUILDING_mail
#define _IMPEXP_MAIL __declspec(dllexport)
#else
#define _IMPEXP_MAIL __declspec(dllimport)
#endif
#if _BUILDING_device
#define _IMPEXP_DEVICE __declspec(dllexport)
#else
#define _IMPEXP_DEVICE __declspec(dllimport)
#endif
#if _BUILDING_media
#define _IMPEXP_MEDIA __declspec(dllexport)
#else
#define _IMPEXP_MEDIA __declspec(dllimport)
#endif
#if _BUILDING_midi2
#define _IMPEXP_MIDI2 __declspec(dllexport)
#else
#define _IMPEXP_MIDI2 __declspec(dllimport)
#endif
#if _BUILDING_midi
#define _IMPEXP_MIDI __declspec(dllexport)
#else
#define _IMPEXP_MIDI __declspec(dllimport)
#endif
#if _BUILDING_game
#define _IMPEXP_GAME __declspec(dllexport)
#else
#define _IMPEXP_GAME __declspec(dllimport)
#endif
#if _BUILDING_gsound
#define _IMPEXP_GSOUND __declspec(dllexport)
#else
#define _IMPEXP_GSOUND __declspec(dllimport)
#endif
#if _BUILDING_translation
#define _IMPEXP_TRANSLATION __declspec(dllexport)
#else
#define _IMPEXP_TRANSLATION __declspec(dllimport)
#endif
#if _BUILDING_textencoding
#define _IMPEXP_TEXTENCODING __declspec(dllexport)
#else
#define _IMPEXP_TEXTENCODING __declspec(dllimport)
#endif
#if _BUILDING_input
#define _IMPEXP_INPUT __declspec(dllexport)
#else
#define _IMPEXP_INPUT __declspec(dllimport)
#endif
#endif /* __INTEL__ */
#if __POWERPC__
#define _EXPORT __declspec(dllexport)
#define _IMPORT __declspec(dllimport)
#define _IMPEXP_KERNEL
#define _IMPEXP_GL
#define _IMPEXP_ROOT
#define _IMPEXP_NET
#define _IMPEXP_NETDEV
#define _IMPEXP_ATALK
#define _IMPEXP_BE
#define _IMPEXP_TRACKER
#define _IMPEXP_MAIL
#define _IMPEXP_DEVICE
#define _IMPEXP_MEDIA
#define _IMPEXP_MIDI
#define _IMPEXP_MIDI2
#define _IMPEXP_GAME
#define _IMPEXP_GSOUND
#define _IMPEXP_TRANSLATION
#define _IMPEXP_TEXTENCODING
#define _IMPEXP_INPUT
#endif
#if __SH__
#define _EXPORT
#define _IMPORT
#define _IMPEXP_KERNEL
#define _IMPEXP_GL
#define _IMPEXP_ROOT
#define _IMPEXP_NET
#define _IMPEXP_NETDEV
#define _IMPEXP_ATALK
#define _IMPEXP_BE
#define _IMPEXP_TRACKER
#define _IMPEXP_MAIL
#define _IMPEXP_DEVICE
#define _IMPEXP_MEDIA
#define _IMPEXP_MIDI
#define _IMPEXP_GAME
#define _IMPEXP_GSOUND
#define _IMPEXP_TRANSLATION
#define _IMPEXP_TEXTENCODING
#define _IMPEXP_INPUT
#endif
#endif
#ifdef __cplusplus
/* cpp kit */
/* -- <typeinfo> */
class _IMPEXP_ROOT bad_cast;
class _IMPEXP_ROOT bad_typeid;
class _IMPEXP_ROOT type_info;
/* -- <exception> */
class _IMPEXP_ROOT exception;
class _IMPEXP_ROOT bad_exception;
/* -- <new.h> */
class _IMPEXP_ROOT bad_alloc;
/* -- <mexcept.h> */
class _IMPEXP_ROOT logic_error;
class _IMPEXP_ROOT domain_error;
class _IMPEXP_ROOT invalid_argument;
class _IMPEXP_ROOT length_error;
class _IMPEXP_ROOT out_of_range;
class _IMPEXP_ROOT runtime_error;
class _IMPEXP_ROOT range_error;
class _IMPEXP_ROOT overflow_error;
/* support kit */
class _IMPEXP_BE BArchivable;
class _IMPEXP_BE BAutolock;
class _IMPEXP_BE BBlockCache;
class _IMPEXP_BE BBufferIO;
class _IMPEXP_BE BDataIO;
class _IMPEXP_BE BPositionIO;
class _IMPEXP_BE BMallocIO;
class _IMPEXP_BE BMemoryIO;
class _IMPEXP_BE BFlattenable;
class _IMPEXP_BE BList;
class _IMPEXP_BE BLocker;
class _IMPEXP_BE BStopWatch;
class _IMPEXP_BE BString;
class _IMPEXP_BE PointerList;
/*storage kit */
struct _IMPEXP_BE entry_ref;
struct _IMPEXP_BE node_ref;
class _IMPEXP_BE BAppFileInfo;
class _IMPEXP_BE BDirectory;
class _IMPEXP_BE BEntry;
class _IMPEXP_BE BFile;
class _IMPEXP_BE BRefFilter;
class _IMPEXP_BE BMimeType;
class _IMPEXP_BE BNode;
class _IMPEXP_BE BNodeInfo;
class _IMPEXP_BE BPath;
class _IMPEXP_BE BQuery;
class _IMPEXP_BE BResources;
class _IMPEXP_BE BResourceStrings;
class _IMPEXP_BE BStatable;
class _IMPEXP_BE BSymLink;
class _IMPEXP_BE BVolume;
class _IMPEXP_BE BVolumeRoster;
class _IMPEXP_BE Partition;
class _IMPEXP_BE Session;
class _IMPEXP_BE Device;
class _IMPEXP_BE DeviceList;
class _IMPEXP_BE TNodeWalker;
class _IMPEXP_BE TQueryWalker;
class _IMPEXP_BE TVolWalker;
/*app kit */
struct _IMPEXP_BE app_info;
class _IMPEXP_BE BApplication;
class _IMPEXP_BE BClipboard;
class _IMPEXP_BE BHandler;
class _IMPEXP_BE BInvoker;
class _IMPEXP_BE BLooper;
class _IMPEXP_BE BMessage;
class _IMPEXP_BE BMessageFilter;
class _IMPEXP_BE BMessageQueue;
class _IMPEXP_BE BMessageRunner;
class _IMPEXP_BE BMessenger;
class _IMPEXP_BE BPropertyInfo;
class _IMPEXP_BE BRoster;
class _IMPEXP_BE _BAppServerLink_;
class _IMPEXP_BE _BSession_;
/*interface kit */
class _IMPEXP_BE BAlert;
class _IMPEXP_BE BBitmap;
class _IMPEXP_BE BBox;
class _IMPEXP_BE BButton;
class _IMPEXP_BE BChannelControl;
class _IMPEXP_BE BChannelSlider;
class _IMPEXP_BE BCheckBox;
class _IMPEXP_BE BColorControl;
class _IMPEXP_BE BControl;
class _IMPEXP_BE BDeskbar;
class _IMPEXP_BE BDragger;
class _IMPEXP_BE BFont;
class _IMPEXP_BE BInputDevice;
class _IMPEXP_BE BListItem;
class _IMPEXP_BE BListView;
class _IMPEXP_BE BStringItem;
class _IMPEXP_BE BMenu;
class _IMPEXP_BE BMenuBar;
class _IMPEXP_BE BMenuField;
class _IMPEXP_BE BMenuItem;
class _IMPEXP_BE BOptionControl;
class _IMPEXP_BE BOptionPopUp;
class _IMPEXP_BE BOutlineListView;
class _IMPEXP_BE BPicture;
class _IMPEXP_BE BPictureButton;
class _IMPEXP_BE BPoint;
class _IMPEXP_BE BPolygon;
class _IMPEXP_BE BPopUpMenu;
class _IMPEXP_BE BPrintJob;
class _IMPEXP_BE BRadioButton;
class _IMPEXP_BE BRect;
class _IMPEXP_BE BRegion;
class _IMPEXP_BE BScreen;
class _IMPEXP_BE BScrollBar;
class _IMPEXP_BE BScrollView;
class _IMPEXP_BE BSeparatorItem;
class _IMPEXP_BE BShelf;
class _IMPEXP_BE BShape;
class _IMPEXP_BE BShapeIterator;
class _IMPEXP_BE BSlider;
class _IMPEXP_BE BStatusBar;
class _IMPEXP_BE BStringView;
class _IMPEXP_BE BTab;
class _IMPEXP_BE BTabView;
class _IMPEXP_BE BTextControl;
class _IMPEXP_BE BTextView;
class _IMPEXP_BE BView;
class _IMPEXP_BE BWindow;
class _IMPEXP_BE _BTextInput_;
class _IMPEXP_BE _BMCMenuBar_;
class _IMPEXP_BE _BMCItem_;
class _IMPEXP_BE _BWidthBuffer_;
class _IMPEXP_BE BPrivateScreen;
/* net kit */
class _IMPEXP_NET _Allocator;
class _IMPEXP_NET _Transacter;
class _IMPEXP_NET _FastIPC;
/* netdev kit */
class _IMPEXP_NETDEV BNetPacket;
class _IMPEXP_NETDEV BStandardPacket;
class _IMPEXP_NETDEV BTimeoutHandler;
class _IMPEXP_NETDEV BPacketHandler;
class _IMPEXP_NETDEV BNetProtocol;
class _IMPEXP_NETDEV BNetDevice;
class _IMPEXP_NETDEV BCallBackHandler;
class _IMPEXP_NETDEV BNetConfig;
class _IMPEXP_NETDEV BIpDevice;
class _IMPEXP_NETDEV _NetBufList;
class _IMPEXP_NETDEV _BSem;
/* atalk kit */
class _IMPEXP_ATALK _PrinterNode;
/* tracker kit */
class _IMPEXP_TRACKER BFilePanel;
class _IMPEXP_TRACKER BRecentItemsList;
class _IMPEXP_TRACKER BRecentFilesList;
class _IMPEXP_TRACKER BRecentFoldersList;
class _IMPEXP_TRACKER BRecentAppsList;
/* mail kit */
class _IMPEXP_MAIL BMailMessage;
/* device kit */
class _IMPEXP_DEVICE BA2D;
class _IMPEXP_DEVICE BD2A;
class _IMPEXP_DEVICE BDigitalPort;
class _IMPEXP_DEVICE BJoystick;
class _IMPEXP_DEVICE BSerialPort;
/* media kit */
class _IMPEXP_MEDIA BDACRenderer;
class _IMPEXP_MEDIA BAudioFileStream;
class _IMPEXP_MEDIA BADCStream;
class _IMPEXP_MEDIA BDACStream;
class _IMPEXP_MEDIA BAbstractBufferStream;
class _IMPEXP_MEDIA BBufferStreamManager;
class _IMPEXP_MEDIA BBufferStream;
class _IMPEXP_MEDIA BSoundFile;
class _IMPEXP_MEDIA BSubscriber;
class _IMPEXP_MEDIA BMediaRoster;
class _IMPEXP_MEDIA BMediaNode;
class _IMPEXP_MEDIA BTimeSource;
class _IMPEXP_MEDIA BBufferProducer;
class _IMPEXP_MEDIA BBufferConsumer;
class _IMPEXP_MEDIA BBuffer;
class _IMPEXP_MEDIA BBufferGroup;
class _IMPEXP_MEDIA BControllable;
class _IMPEXP_MEDIA BFileInterface;
class _IMPEXP_MEDIA BEntityInterface;
class _IMPEXP_MEDIA BMediaAddOn;
class _IMPEXP_MEDIA BMediaTheme;
class _IMPEXP_MEDIA BParameterWeb;
class _IMPEXP_MEDIA BParameterGroup;
class _IMPEXP_MEDIA BParameter;
class _IMPEXP_MEDIA BNullParameter;
class _IMPEXP_MEDIA BDiscreteParameter;
class _IMPEXP_MEDIA BContinuousParameter;
class _IMPEXP_MEDIA BMediaFiles;
class _IMPEXP_MEDIA BSound;
class _IMPEXP_MEDIA BSoundCard;
class _IMPEXP_MEDIA BSoundPlayer;
class _IMPEXP_MEDIA BMediaFormats;
class _IMPEXP_MEDIA BTimedEventQueue;
//class _IMPEXP_MEDIA BEventIterator;
class _IMPEXP_MEDIA BMediaEventLooper;
class _IMPEXP_MEDIA BMediaFile;
class _IMPEXP_MEDIA BMediaTrack;
class _IMPEXP_MEDIA media_node;
struct _IMPEXP_MEDIA media_input;
struct _IMPEXP_MEDIA media_output;
struct _IMPEXP_MEDIA live_node_info;
struct _IMPEXP_MEDIA buffer_clone_info;
struct _IMPEXP_MEDIA media_source;
struct _IMPEXP_MEDIA media_destination;
struct _IMPEXP_MEDIA media_raw_audio_format;
struct _IMPEXP_MEDIA media_raw_video_format;
struct _IMPEXP_MEDIA media_video_display_info;
struct _IMPEXP_MEDIA flavor_info;
struct _IMPEXP_MEDIA dormant_node_info;
struct _IMPEXP_MEDIA dormant_flavor_info;
struct _IMPEXP_MEDIA media_source;
struct _IMPEXP_MEDIA media_destination;
struct _IMPEXP_MEDIA _media_format_description;
struct _IMPEXP_MEDIA media_timed_event;
/* midi kit */
class _IMPEXP_MIDI BMidi;
class _IMPEXP_MIDI BMidiPort;
class _IMPEXP_MIDI BMidiStore;
class _IMPEXP_MIDI BMidiSynth;
class _IMPEXP_MIDI BMidiSynthFile;
class _IMPEXP_MIDI BMidiText;
class _IMPEXP_MIDI BSamples;
class _IMPEXP_MIDI BSynth;
class _IMPEXP_MIDI2 BMidiEndpoint;
class _IMPEXP_MIDI2 BMidiProducer;
class _IMPEXP_MIDI2 BMidiConsumer;
class _IMPEXP_MIDI2 BMidiLocalProducer;
class _IMPEXP_MIDI2 BMidiLocalConsumer;
class _IMPEXP_MIDI2 BMidiRoster;
/* game kit */
class _IMPEXP_GAME BWindowScreen;
class _IMPEXP_GAME BDirectWindow;
/* gamesound kit */
class _IMPEXP_GSOUND BGameSound;
class _IMPEXP_GSOUND BSimpleGameSound;
class _IMPEXP_GSOUND BStreamingGameSound;
class _IMPEXP_GSOUND BFileGameSound;
class _IMPEXP_GSOUND BPushGameSound;
/* translation kit */
class _IMPEXP_TRANSLATION BTranslatorRoster;
class _IMPEXP_TRANSLATION BTranslationUtils;
class _IMPEXP_TRANSLATION BBitmapStream;
class _IMPEXP_TRANSLATION BTranslator;
struct _IMPEXP_TRANSLATION translation_format;
struct _IMPEXP_TRANSLATION translator_info;
/* GL */
class _IMPEXP_GL BGLView;
class _IMPEXP_GL BGLScreen;
#ifdef __cplusplus
class _IMPEXP_GL GLUnurbs;
class _IMPEXP_GL GLUquadric;
class _IMPEXP_GL GLUtesselator;
typedef class _IMPEXP_GL GLUnurbs GLUnurbsObj;
typedef class _IMPEXP_GL GLUquadric GLUquadricObj;
typedef class _IMPEXP_GL GLUtesselator GLUtesselatorObj;
typedef class _IMPEXP_GL GLUtesselator GLUtriangulatorObj;
#else
typedef struct _IMPEXP_GL GLUnurbs GLUnurbs;
typedef struct _IMPEXP_GL GLUquadric GLUquadric;
typedef struct _IMPEXP_GL GLUtesselator GLUtesselator;
typedef struct _IMPEXP_GL GLUnurbs GLUnurbsObj;
typedef struct _IMPEXP_GL GLUquadric GLUquadricObj;
typedef struct _IMPEXP_GL GLUtesselator GLUtesselatorObj;
typedef struct _IMPEXP_GL GLUtesselator GLUtriangulatorObj;
#endif
/* input_server */
class _IMPEXP_INPUT BInputServerDevice;
class _IMPEXP_INPUT BInputServerFilter;
class _IMPEXP_INPUT BInputServerMethod;
#endif /* __cplusplus */
#endif
+246
View File
@@ -0,0 +1,246 @@
/*
Copyright 1999-2001, Be Incorporated. All Rights Reserved.
This file may be used under the terms of the Be Sample Code License.
*/
#ifndef _FSPROTO_H
#define _FSPROTO_H
#include <sys/dirent.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <unistd.h>
#include <iovec.h>
#include <OS.h>
#include <fs_attr.h>
#include <fs_info.h>
#include <BeBuild.h>
#include <Drivers.h>
typedef dev_t nspace_id;
typedef ino_t vnode_id;
/*
* PUBLIC PART OF THE FILE SYSTEM PROTOCOL
*/
#define WSTAT_MODE 0x0001
#define WSTAT_UID 0x0002
#define WSTAT_GID 0x0004
#define WSTAT_SIZE 0x0008
#define WSTAT_ATIME 0x0010
#define WSTAT_MTIME 0x0020
#define WSTAT_CRTIME 0x0040
#define WFSSTAT_NAME 0x0001
#define B_ENTRY_CREATED 1
#define B_ENTRY_REMOVED 2
#define B_ENTRY_MOVED 3
#define B_STAT_CHANGED 4
#define B_ATTR_CHANGED 5
#define B_DEVICE_MOUNTED 6
#define B_DEVICE_UNMOUNTED 7
#define B_STOP_WATCHING 0x0000
#define B_WATCH_NAME 0x0001
#define B_WATCH_STAT 0x0002
#define B_WATCH_ATTR 0x0004
#define B_WATCH_DIRECTORY 0x0008
#define SELECT_READ 1
#define SELECT_WRITE 2
#define SELECT_EXCEPTION 3
#define B_CUR_FS_API_VERSION 2
struct attr_info;
struct index_info;
typedef int op_read_vnode(void *ns, vnode_id vnid, char r, void **node);
typedef int op_write_vnode(void *ns, void *node, char r);
typedef int op_remove_vnode(void *ns, void *node, char r);
typedef int op_secure_vnode(void *ns, void *node);
typedef int op_walk(void *ns, void *base, const char *file, char **newpath,
vnode_id *vnid);
typedef int op_access(void *ns, void *node, int mode);
typedef int op_create(void *ns, void *dir, const char *name,
int omode, int perms, vnode_id *vnid, void **cookie);
typedef int op_mkdir(void *ns, void *dir, const char *name, int perms);
typedef int op_symlink(void *ns, void *dir, const char *name,
const char *path);
typedef int op_link(void *ns, void *dir, const char *name, void *node);
typedef int op_rename(void *ns, void *olddir, const char *oldname,
void *newdir, const char *newname);
typedef int op_unlink(void *ns, void *dir, const char *name);
typedef int op_rmdir(void *ns, void *dir, const char *name);
typedef int op_readlink(void *ns, void *node, char *buf, size_t *bufsize);
typedef int op_opendir(void *ns, void *node, void **cookie);
typedef int op_closedir(void *ns, void *node, void *cookie);
typedef int op_rewinddir(void *ns, void *node, void *cookie);
typedef int op_readdir(void *ns, void *node, void *cookie, long *num,
struct dirent *buf, size_t bufsize);
typedef int op_open(void *ns, void *node, int omode, void **cookie);
typedef int op_close(void *ns, void *node, void *cookie);
typedef int op_free_cookie(void *ns, void *node, void *cookie);
typedef int op_read(void *ns, void *node, void *cookie, off_t pos, void *buf,
size_t *len);
typedef int op_write(void *ns, void *node, void *cookie, off_t pos,
const void *buf, size_t *len);
typedef int op_readv(void *ns, void *node, void *cookie, off_t pos, const iovec *vec,
size_t count, size_t *len);
typedef int op_writev(void *ns, void *node, void *cookie, off_t pos, const iovec *vec,
size_t count, size_t *len);
typedef int op_ioctl(void *ns, void *node, void *cookie, int cmd, void *buf,
size_t len);
typedef int op_setflags(void *ns, void *node, void *cookie, int flags);
typedef int op_rstat(void *ns, void *node, struct stat *);
typedef int op_wstat(void *ns, void *node, struct stat *, long mask);
typedef int op_fsync(void *ns, void *node);
typedef int op_select(void *ns, void *node, void *cookie, uint8 event,
uint32 ref, selectsync *sync);
typedef int op_deselect(void *ns, void *node, void *cookie, uint8 event,
selectsync *sync);
typedef int op_initialize(const char *devname, void *parms, size_t len);
typedef int op_mount(nspace_id nsid, const char *devname, ulong flags,
void *parms, size_t len, void **data, vnode_id *vnid);
typedef int op_unmount(void *ns);
typedef int op_sync(void *ns);
typedef int op_rfsstat(void *ns, struct fs_info *);
typedef int op_wfsstat(void *ns, struct fs_info *, long mask);
typedef int op_open_attrdir(void *ns, void *node, void **cookie);
typedef int op_close_attrdir(void *ns, void *node, void *cookie);
typedef int op_rewind_attrdir(void *ns, void *node, void *cookie);
typedef int op_read_attrdir(void *ns, void *node, void *cookie, long *num,
struct dirent *buf, size_t bufsize);
typedef int op_remove_attr(void *ns, void *node, const char *name);
typedef int op_rename_attr(void *ns, void *node, const char *oldname,
const char *newname);
typedef int op_stat_attr(void *ns, void *node, const char *name,
struct attr_info *buf);
typedef int op_write_attr(void *ns, void *node, const char *name, int type,
const void *buf, size_t *len, off_t pos);
typedef int op_read_attr(void *ns, void *node, const char *name, int type,
void *buf, size_t *len, off_t pos);
typedef int op_open_indexdir(void *ns, void **cookie);
typedef int op_close_indexdir(void *ns, void *cookie);
typedef int op_rewind_indexdir(void *ns, void *cookie);
typedef int op_read_indexdir(void *ns, void *cookie, long *num,
struct dirent *buf, size_t bufsize);
typedef int op_create_index(void *ns, const char *name, int type, int flags);
typedef int op_remove_index(void *ns, const char *name);
typedef int op_rename_index(void *ns, const char *oldname,
const char *newname);
typedef int op_stat_index(void *ns, const char *name, struct index_info *buf);
typedef int op_open_query(void *ns, const char *query, ulong flags,
port_id port, long token, void **cookie);
typedef int op_close_query(void *ns, void *cookie);
typedef int op_read_query(void *ns, void *cookie, long *num,
struct dirent *buf, size_t bufsize);
typedef struct vnode_ops {
op_read_vnode (*read_vnode);
op_write_vnode (*write_vnode);
op_remove_vnode (*remove_vnode);
op_secure_vnode (*secure_vnode);
op_walk (*walk);
op_access (*access);
op_create (*create);
op_mkdir (*mkdir);
op_symlink (*symlink);
op_link (*link);
op_rename (*rename);
op_unlink (*unlink);
op_rmdir (*rmdir);
op_readlink (*readlink);
op_opendir (*opendir);
op_closedir (*closedir);
op_free_cookie (*free_dircookie);
op_rewinddir (*rewinddir);
op_readdir (*readdir);
op_open (*open);
op_close (*close);
op_free_cookie (*free_cookie);
op_read (*read);
op_write (*write);
op_readv (*readv);
op_writev (*writev);
op_ioctl (*ioctl);
op_setflags (*setflags);
op_rstat (*rstat);
op_wstat (*wstat);
op_fsync (*fsync);
op_initialize (*initialize);
op_mount (*mount);
op_unmount (*unmount);
op_sync (*sync);
op_rfsstat (*rfsstat);
op_wfsstat (*wfsstat);
op_select (*select);
op_deselect (*deselect);
op_open_indexdir (*open_indexdir);
op_close_indexdir (*close_indexdir);
op_free_cookie (*free_indexdircookie);
op_rewind_indexdir (*rewind_indexdir);
op_read_indexdir (*read_indexdir);
op_create_index (*create_index);
op_remove_index (*remove_index);
op_rename_index (*rename_index);
op_stat_index (*stat_index);
op_open_attrdir (*open_attrdir);
op_close_attrdir (*close_attrdir);
op_free_cookie (*free_attrdircookie);
op_rewind_attrdir (*rewind_attrdir);
op_read_attrdir (*read_attrdir);
op_write_attr (*write_attr);
op_read_attr (*read_attr);
op_remove_attr (*remove_attr);
op_rename_attr (*rename_attr);
op_stat_attr (*stat_attr);
op_open_query (*open_query);
op_close_query (*close_query);
op_free_cookie (*free_querycookie);
op_read_query (*read_query);
} vnode_ops;
extern _IMPEXP_KERNEL int new_path(const char *path, char **copy);
extern _IMPEXP_KERNEL void free_path(char *p);
extern _IMPEXP_KERNEL int notify_listener(int op, nspace_id nsid,
vnode_id vnida, vnode_id vnidb,
vnode_id vnidc, const char *name);
extern _IMPEXP_KERNEL void notify_select_event(selectsync *sync, uint32 ref);
extern _IMPEXP_KERNEL int send_notification(port_id port, long token,
ulong what, long op, nspace_id nsida,
nspace_id nsidb, vnode_id vnida,
vnode_id vnidb, vnode_id vnidc,
const char *name);
extern _IMPEXP_KERNEL int get_vnode(nspace_id nsid, vnode_id vnid, void **data);
extern _IMPEXP_KERNEL int put_vnode(nspace_id nsid, vnode_id vnid);
extern _IMPEXP_KERNEL int new_vnode(nspace_id nsid, vnode_id vnid, void *data);
extern _IMPEXP_KERNEL int remove_vnode(nspace_id nsid, vnode_id vnid);
extern _IMPEXP_KERNEL int unremove_vnode(nspace_id nsid, vnode_id vnid);
extern _IMPEXP_KERNEL int is_vnode_removed(nspace_id nsid, vnode_id vnid);
extern _EXPORT vnode_ops fs_entry;
extern _EXPORT int32 api_version;
#endif
@@ -0,0 +1,79 @@
/******************************************************************************
/
/ File: InputServerDevice.h
/
/ Description: Add-on class for input_server devices.
/
/ Copyright 1998, Be Incorporated, All Rights Reserved.
/
******************************************************************************/
#ifndef _INPUTSERVERDEVICE_H
#define _INPUTSERVERDEVICE_H
#include <BeBuild.h>
#include <Input.h>
#include <SupportDefs.h>
struct input_device_ref {
char *name;
input_device_type type;
void *cookie;
};
enum {
// B_KEYBOARD_DEVICE notifications
B_KEY_MAP_CHANGED = 1,
B_KEY_LOCKS_CHANGED,
B_KEY_REPEAT_DELAY_CHANGED,
B_KEY_REPEAT_RATE_CHANGED,
// B_POINTING_DEVICE notifications
B_MOUSE_TYPE_CHANGED,
B_MOUSE_MAP_CHANGED,
B_MOUSE_SPEED_CHANGED,
B_CLICK_SPEED_CHANGED,
B_MOUSE_ACCELERATION_CHANGED
};
class _BDeviceAddOn_;
class BInputServerDevice {
public:
BInputServerDevice();
virtual ~BInputServerDevice();
virtual status_t InitCheck();
virtual status_t SystemShuttingDown();
virtual status_t Start(const char *device, void *cookie);
virtual status_t Stop(const char *device, void *cookie);
virtual status_t Control(const char *device,
void *cookie,
uint32 code,
BMessage *message);
status_t RegisterDevices(input_device_ref **devices);
status_t UnregisterDevices(input_device_ref **devices);
status_t EnqueueMessage(BMessage *message);
status_t StartMonitoringDevice(const char *device);
status_t StopMonitoringDevice(const char *device);
private:
_BDeviceAddOn_* fOwner;
virtual void _ReservedInputServerDevice1();
virtual void _ReservedInputServerDevice2();
virtual void _ReservedInputServerDevice3();
virtual void _ReservedInputServerDevice4();
uint32 _reserved[4];
};
#endif
@@ -0,0 +1,39 @@
/******************************************************************************
/
/ File: InputServerFilter.h
/
/ Description: Add-on class for input_server filters.
/
/ Copyright 1998, Be Incorporated, All Rights Reserved.
/
*******************************************************************************/
#ifndef _INPUTSERVERFILTER_H
#define _INPUTSERVERFILTER_H
#include <BeBuild.h>
#include <MessageFilter.h>
#include <SupportDefs.h>
class BInputServerFilter {
public:
BInputServerFilter();
virtual ~BInputServerFilter();
virtual status_t InitCheck();
virtual filter_result Filter(BMessage *message, BList *outList);
status_t GetScreenRegion(BRegion *region) const;
private:
virtual void _ReservedInputServerFilter1();
virtual void _ReservedInputServerFilter2();
virtual void _ReservedInputServerFilter3();
virtual void _ReservedInputServerFilter4();
uint32 _reserved[4];
};
#endif
@@ -0,0 +1,47 @@
/******************************************************************************
/
/ File: InputServerMethod.h
/
/ Description: Add-on class for input_server methods.
/
/ Copyright 1998, Be Incorporated, All Rights Reserved.
/
/******************************************************************************/
#ifndef _INPUTSERVERMETHOD_H
#define _INPUTSERVERMETHOD_H
#include <BeBuild.h>
#include <InputServerFilter.h>
#include <SupportDefs.h>
class _BMethodAddOn_;
class BInputServerMethod : public BInputServerFilter {
public:
BInputServerMethod(const char *name,
const uchar *icon);
virtual ~BInputServerMethod();
virtual status_t MethodActivated(bool active);
status_t EnqueueMessage(BMessage *message);
status_t SetName(const char *name);
status_t SetIcon(const uchar *icon);
status_t SetMenu(const BMenu *menu, const BMessenger target);
private:
_BMethodAddOn_* fOwner;
virtual void _ReservedInputServerMethod1();
virtual void _ReservedInputServerMethod2();
virtual void _ReservedInputServerMethod3();
virtual void _ReservedInputServerMethod4();
uint32 _reserved[4];
};
#endif
+167
View File
@@ -0,0 +1,167 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: AppDefs.h
// Author: Erik Jaesler ([email protected])
// Description: Message codes and the global cursors.
//------------------------------------------------------------------------------
#ifndef _APP_DEFS_H
#define _APP_DEFS_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
// Global Cursors --------------------------------------------------------------
// Old-style cursors
extern const unsigned char B_HAND_CURSOR[];
extern const unsigned char B_I_BEAM_CURSOR[];
// New-style cursors
#ifdef __cplusplus
class BCursor;
extern const BCursor *B_CURSOR_SYSTEM_DEFAULT;
extern const BCursor *B_CURSOR_I_BEAM;
#endif
// System Message Codes --------------------------------------------------------
enum {
B_ABOUT_REQUESTED = '_ABR',
B_WINDOW_ACTIVATED = '_ACT',
B_APP_ACTIVATED = '_ACT', // Same as B_WINDOW_ACTIVATED
B_ARGV_RECEIVED = '_ARG',
B_QUIT_REQUESTED = '_QRQ',
B_CLOSE_REQUESTED = '_QRQ', // Obsolete; use B_QUIT_REQUESTED
B_CANCEL = '_CNC',
B_KEY_DOWN = '_KYD',
B_KEY_UP = '_KYU',
B_UNMAPPED_KEY_DOWN = '_UKD',
B_UNMAPPED_KEY_UP = '_UKU',
B_MODIFIERS_CHANGED = '_MCH',
B_MINIMIZE = '_WMN',
B_MOUSE_DOWN = '_MDN',
B_MOUSE_MOVED = '_MMV',
B_MOUSE_ENTER_EXIT = '_MEX',
B_MOUSE_UP = '_MUP',
B_MOUSE_WHEEL_CHANGED = '_MWC',
B_OPEN_IN_WORKSPACE = '_OWS',
B_PRINTER_CHANGED = '_PCH',
B_PULSE = '_PUL',
B_READY_TO_RUN = '_RTR',
B_REFS_RECEIVED = '_RRC',
B_RELEASE_OVERLAY_LOCK = '_ROV',
B_ACQUIRE_OVERLAY_LOCK = '_AOV',
B_SCREEN_CHANGED = '_SCH',
B_VALUE_CHANGED = '_VCH',
B_VIEW_MOVED = '_VMV',
B_VIEW_RESIZED = '_VRS',
B_WINDOW_MOVED = '_WMV',
B_WINDOW_RESIZED = '_WRS',
B_WORKSPACES_CHANGED = '_WCG',
B_WORKSPACE_ACTIVATED = '_WAC',
B_ZOOM = '_WZM',
_APP_MENU_ = '_AMN',
_BROWSER_MENUS_ = '_BRM',
_MENU_EVENT_ = '_MEV',
_PING_ = '_PBL',
_QUIT_ = '_QIT',
_VOLUME_MOUNTED_ = '_NVL',
_VOLUME_UNMOUNTED_ = '_VRM',
_MESSAGE_DROPPED_ = '_MDP',
_DISPOSE_DRAG_ = '_DPD',
_MENUS_DONE_ = '_MND',
_SHOW_DRAG_HANDLES_ = '_SDH',
_EVENTS_PENDING_ = '_EVP',
_UPDATE_ = '_UPD',
_UPDATE_IF_NEEDED_ = '_UPN',
_PRINTER_INFO_ = '_PIN',
_SETUP_PRINTER_ = '_SUP',
_SELECT_PRINTER_ = '_PSL'
// Media Kit reserves all reserved codes starting in '_TR'
};
// Other Commands --------------------------------------------------------------
enum {
B_SET_PROPERTY = 'PSET',
B_GET_PROPERTY = 'PGET',
B_CREATE_PROPERTY = 'PCRT',
B_DELETE_PROPERTY = 'PDEL',
B_COUNT_PROPERTIES = 'PCNT',
B_EXECUTE_PROPERTY = 'PEXE',
B_GET_SUPPORTED_SUITES = 'SUIT',
B_UNDO = 'UNDO',
B_CUT = 'CCUT',
B_COPY = 'COPY',
B_PASTE = 'PSTE',
B_SELECT_ALL = 'SALL',
B_SAVE_REQUESTED = 'SAVE',
B_MESSAGE_NOT_UNDERSTOOD = 'MNOT',
B_NO_REPLY = 'NONE',
B_REPLY = 'RPLY',
B_SIMPLE_DATA = 'DATA',
B_MIME_DATA = 'MIME',
B_ARCHIVED_OBJECT = 'ARCV',
B_UPDATE_STATUS_BAR = 'SBUP',
B_RESET_STATUS_BAR = 'SBRS',
B_NODE_MONITOR = 'NDMN',
B_QUERY_UPDATE = 'QUPD',
B_ENDORSABLE = 'ENDO',
B_COPY_TARGET = 'DDCP',
B_MOVE_TARGET = 'DDMV',
B_TRASH_TARGET = 'DDRM',
B_LINK_TARGET = 'DDLN',
B_INPUT_DEVICES_CHANGED = 'IDCH',
B_INPUT_METHOD_EVENT = 'IMEV',
B_WINDOW_MOVE_TO = 'WDMT',
B_WINDOW_MOVE_BY = 'WDMB',
B_SILENT_RELAUNCH = 'AREL',
B_OBSERVER_NOTICE_CHANGE = 'NTCH',
B_CONTROL_INVOKED = 'CIVK',
B_CONTROL_MODIFIED = 'CMOD'
// Media Kit reserves all reserved codes starting in 'TRI'
};
//------------------------------------------------------------------------------
#endif // _APP_DEFS_H
/*
* $Log $
*
* $Id $
*
*/
+223
View File
@@ -0,0 +1,223 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Application.h
// Author: Erik Jaesler ([email protected])
// Description: BApplication class is the center of the application
// universe. The global be_app and be_app_messenger
// variables are defined here as well.
//------------------------------------------------------------------------------
#ifndef _APPLICATION_H
#define _APPLICATION_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <AppDefs.h> // For convenience
#include <InterfaceDefs.h>
#include <Looper.h>
#include <Messenger.h>
#include <Point.h>
#include <Rect.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class BCursor;
class BList;
class BWindow;
class _BSession_;
class BResources;
class BMessageRunner;
struct _server_heap_;
struct _drag_data_;
// BApplication class ----------------------------------------------------------
class BApplication : public BLooper {
public:
BApplication(const char* signature);
BApplication(const char* signature,
status_t* error);
virtual ~BApplication();
// Archiving
BApplication(BMessage* data);
static BArchivable* Instantiate(BMessage* data);
virtual status_t Archive(BMessage* data, bool deep = true) const;
status_t InitCheck() const;
// App control and System Message handling
virtual thread_id Run();
virtual void Quit();
virtual bool QuitRequested();
virtual void Pulse();
virtual void ReadyToRun();
virtual void MessageReceived(BMessage* msg);
virtual void ArgvReceived(int32 argc, char** argv);
virtual void AppActivated(bool active);
virtual void RefsReceived(BMessage* a_message);
virtual void AboutRequested();
// Scripting
virtual BHandler* ResolveSpecifier(BMessage* msg,
int32 index,
BMessage* specifier,
int32 form,
const char* property);
// Cursor control, window/looper list, and app info
void ShowCursor();
void HideCursor();
void ObscureCursor();
bool IsCursorHidden() const;
void SetCursor(const void* cursor);
void SetCursor(const BCursor* cursor, bool sync = true);
int32 CountWindows() const;
BWindow* WindowAt(int32 index) const;
int32 CountLoopers() const;
BLooper* LooperAt(int32 index) const;
bool IsLaunching() const;
status_t GetAppInfo(app_info* info) const;
static BResources* AppResources();
virtual void DispatchMessage(BMessage* an_event,
BHandler* handler);
void SetPulseRate(bigtime_t rate);
// More scripting
virtual status_t GetSupportedSuites(BMessage* data);
// Private or reserved ---------------------------------------------------------
virtual status_t Perform(perform_code d, void* arg);
private:
typedef BLooper _inherited;
friend class BWindow;
friend class BView;
friend class BBitmap;
friend class BScrollBar;
friend class BPrivateScreen;
friend class _BAppServerLink_;
friend void _toggle_handles_(bool);
BApplication(uint32 signature);
BApplication(const BApplication&);
BApplication& operator=(const BApplication&);
virtual void _ReservedApplication1();
virtual void _ReservedApplication2();
virtual void _ReservedApplication3();
virtual void _ReservedApplication4();
virtual void _ReservedApplication5();
virtual void _ReservedApplication6();
virtual void _ReservedApplication7();
virtual void _ReservedApplication8();
virtual bool ScriptReceived(BMessage* msg,
int32 index,
BMessage* specifier,
int32 form,
const char* property);
void run_task();
void InitData(const char* signature, status_t* error);
void BeginRectTracking(BRect r, bool trackWhole);
void EndRectTracking();
void get_scs();
void setup_server_heaps();
void* rw_offs_to_ptr(uint32 offset);
void* ro_offs_to_ptr(uint32 offset);
void* global_ro_offs_to_ptr(uint32 offset);
void connect_to_app_server();
void send_drag( BMessage* msg,
int32 vs_token,
BPoint offset,
BRect drag_rect,
BHandler* reply_to);
void send_drag( BMessage* msg,
int32 vs_token,
BPoint offset,
int32 bitmap_token,
drawing_mode dragMode,
BHandler* reply_to);
void write_drag(_BSession_* session, BMessage* a_message);
bool quit_all_windows(bool force);
bool window_quit_loop(bool, bool);
void do_argv(BMessage* msg);
#ifndef FIX_FOR_4_6
void SetAppCursor();
#endif
uint32 InitialWorkspace();
int32 count_windows(bool incl_menus) const;
BWindow* window_at(uint32 index, bool incl_menus) const;
status_t get_window_list(BList* list, bool incl_menus) const;
static int32 async_quit_entry(void*);
static BResources* _app_resources;
static BLocker _app_resources_lock;
const char* fAppName;
int32 fServerFrom;
int32 fServerTo;
#ifndef FIX_FOR_4_6
void* fCursorData;
#else
void* _unused1;
#endif
_server_heap_* fServerHeap;
bigtime_t fPulseRate;
uint32 fInitialWorkspace;
_drag_data_* fDraggedMessage;
BMessageRunner* fPulseRunner;
status_t fInitError;
uint32 _reserved[11];
bool fReadyToRunCalled;
};
//------------------------------------------------------------------------------
// Global Objects --------------------------------------------------------------
extern _IMPEXP_BE BApplication* be_app;
extern _IMPEXP_BE BMessenger be_app_messenger;
//------------------------------------------------------------------------------
#endif // _APPLICATION_H
/*
* $Log $
*
* $Id $
*
*/
+82
View File
@@ -0,0 +1,82 @@
/******************************************************************************
/
/ File: Clipboard.h
/
/ Description: BClipboard class defines clipboard functionality.
/ The global be_clipboard represents the default clipboard.
/
/ Copyright 1995-98, Be Incorporated, All Rights Reserved.
/
*******************************************************************************/
#ifndef _CLIPBOARD_H
#define _CLIPBOARD_H
#include <BeBuild.h>
#include <Messenger.h>
#include <Locker.h>
class BMessage;
enum {
B_CLIPBOARD_CHANGED = 'CLCH'
};
/*------------------------------------------------------------------*/
/*----- BClipboard class --------------------------------------------*/
class BClipboard {
public:
BClipboard(const char *name, bool transient = false);
virtual ~BClipboard();
const char *Name() const;
uint32 LocalCount() const;
uint32 SystemCount() const;
status_t StartWatching(BMessenger target);
status_t StopWatching(BMessenger target);
bool Lock();
void Unlock();
bool IsLocked() const;
status_t Clear();
status_t Commit();
status_t Revert();
BMessenger DataSource() const;
BMessage *Data() const;
/*----- Private or reserved -----------------------------------------*/
private:
BClipboard(const BClipboard &);
BClipboard &operator=(const BClipboard &);
virtual void _ReservedClipboard1();
virtual void _ReservedClipboard2();
virtual void _ReservedClipboard3();
bool AssertLocked() const;
status_t DownloadFromSystem(bool force = false);
status_t UploadToSystem();
uint32 fCount;
BMessage *fData;
BLocker fLock;
BMessenger fClipHandler;
BMessenger fDataSource;
uint32 fSystemCount;
char *fName;
uint32 _reserved[4];
};
/*----------------------------------------------------------------*/
/*----- Global Clipboard -----------------------------------------*/
extern _IMPEXP_BE BClipboard *be_clipboard;
/*-------------------------------------------------------------*/
/*-------------------------------------------------------------*/
#endif /* _CLIPBOARD_H */
+83
View File
@@ -0,0 +1,83 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Cursor.h
// Author: Frans van Nispen ([email protected])
// Description: BCursor describes a view-wide or application-wide cursor.
//------------------------------------------------------------------------------
#ifndef _CURSOR_H
#define _CURSOR_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <Archivable.h>
#include <BeBuild.h>
#include <InterfaceDefs.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
// BCursor class ---------------------------------------------------------------
class BCursor : BArchivable {
public:
BCursor(const void* cursorData);
BCursor(BMessage* data);
virtual ~BCursor();
virtual status_t Archive(BMessage* into, bool deep = true) const;
static BArchivable* Instantiate(BMessage* data);
// Private or reserved ---------------------------------------------------------
virtual status_t Perform(perform_code d, void* arg);
private:
virtual void _ReservedCursor1();
virtual void _ReservedCursor2();
virtual void _ReservedCursor3();
virtual void _ReservedCursor4();
friend class BApplication;
friend class BView;
int32 m_serverToken;
int32 m_needToFree;
uint32 _reserved[6];
};
//------------------------------------------------------------------------------
#endif // _CURSOR_H
/*
* $Log $
*
* $Id $
*
*/
+148
View File
@@ -0,0 +1,148 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Handler.cpp
// Author: Erik Jaesler ([email protected])
// Description: BHandler defines the message-handling protocol.
// MessageReceived() is its lynchpin.
//------------------------------------------------------------------------------
#ifndef _HANDLER_H
#define _HANDLER_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <Archivable.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class BLooper;
class BMessageFilter;
class BMessage;
class BList;
class _ObserverList;
#define B_OBSERVE_WHAT_CHANGE "be:observe_change_what"
#define B_OBSERVE_ORIGINAL_WHAT "be:observe_orig_what"
const uint32 B_OBSERVER_OBSERVE_ALL = 0xffffffff;
// BHandler class --------------------------------------------------------------
class BHandler : public BArchivable {
public:
BHandler(const char* name = NULL);
virtual ~BHandler();
// Archiving
BHandler(BMessage* data);
static BArchivable* Instantiate(BMessage* data);
virtual status_t Archive(BMessage* data, bool deep = true) const;
// BHandler guts.
virtual void MessageReceived(BMessage* message);
BLooper* Looper() const;
void SetName(const char* name);
const char* Name() const;
virtual void SetNextHandler(BHandler* handler);
BHandler* NextHandler() const;
// Message filtering
virtual void AddFilter(BMessageFilter* filter);
virtual bool RemoveFilter(BMessageFilter* filter);
virtual void SetFilterList(BList* filters);
BList* FilterList();
bool LockLooper();
status_t LockLooperWithTimeout(bigtime_t timeout);
void UnlockLooper();
// Scripting
virtual BHandler* ResolveSpecifier(BMessage* msg,
int32 index,
BMessage* specifier,
int32 form,
const char* property);
virtual status_t GetSupportedSuites(BMessage* data);
// Observer calls, inter-looper and inter-team
status_t StartWatching(BMessenger, uint32 what);
status_t StartWatchingAll(BMessenger);
status_t StopWatching(BMessenger, uint32 what);
status_t StopWatchingAll(BMessenger);
// Observer calls for observing targets in the same BLooper
status_t StartWatching(BHandler* , uint32 what);
status_t StartWatchingAll(BHandler* );
status_t StopWatching(BHandler* , uint32 what);
status_t StopWatchingAll(BHandler* );
// Reserved
virtual status_t Perform(perform_code d, void* arg);
// Notifier calls
virtual void SendNotices(uint32 what, const BMessage* = 0);
bool IsWatched() const;
//----- Private or reserved -----------------------------------------
private:
typedef BArchivable _inherited;
friend inline int32 _get_object_token_(const BHandler* );
friend class BLooper;
friend class BMessageFilter;
virtual void _ReservedHandler2();
virtual void _ReservedHandler3();
virtual void _ReservedHandler4();
void InitData(const char* name);
BHandler(const BHandler&);
BHandler& operator=(const BHandler&);
void SetLooper(BLooper* loop);
int32 fToken;
char* fName;
BLooper* fLooper;
BHandler* fNextHandler;
BList* fFilters;
_ObserverList* fObserverList;
uint32 _reserved[3];
};
//------------------------------------------------------------------------------
#endif // _HANDLER_H
/*
* $Log $
*
* $Id $
*
*/
+128
View File
@@ -0,0 +1,128 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Invoker.h
// Author: Frans van Nispen ([email protected])
// Description: BInvoker class defines a protocol for objects that
// post messages to a "target".
//------------------------------------------------------------------------------
#ifndef _INVOKER_H
#define _INVOKER_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <Messenger.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class BHandler;
class BLooper;
class BMessage;
// BInvoker class --------------------------------------------------------------
class BInvoker {
public:
BInvoker();
BInvoker(BMessage *message,
const BHandler *handler,
const BLooper *looper = NULL);
BInvoker(BMessage *message, BMessenger target);
virtual ~BInvoker();
virtual status_t SetMessage(BMessage *message);
BMessage *Message() const;
uint32 Command() const;
virtual status_t SetTarget(const BHandler *h, const BLooper *loop = NULL);
virtual status_t SetTarget(BMessenger messenger);
bool IsTargetLocal() const;
BHandler *Target(BLooper **looper = NULL) const;
BMessenger Messenger() const;
virtual status_t SetHandlerForReply(BHandler *handler);
BHandler *HandlerForReply() const;
virtual status_t Invoke(BMessage *msg = NULL);
// Invoke with BHandler notification. Use this to perform an
// Invoke() with some other kind of notification change code.
// (A raw invoke should always notify as B_CONTROL_INVOKED.)
// Unlike a raw Invoke(), there is no standard message that is
// sent. If 'msg' is NULL, then nothing will be sent to this
// invoker's target... however, a notification message will
// still be sent to any watchers of the invoker's handler.
// Note that the BInvoker class does not actually implement
// any of this behavior -- it is up to subclasses to override
// Invoke() and call Notify() with the appropriate change code.
status_t InvokeNotify(BMessage *msg, uint32 kind = B_CONTROL_INVOKED);
status_t SetTimeout(bigtime_t timeout);
bigtime_t Timeout() const;
protected:
// Return the change code for a notification. This is either
// B_CONTROL_INVOKED for raw Invoke() calls, or the kind
// supplied to InvokeNotify(). In addition, 'notify' will be
// set to true if this was an InvokeNotify() call, else false.
uint32 InvokeKind(bool* notify = NULL);
// Start and end an InvokeNotify context around an Invoke() call.
// These are only needed for writing custom methods that
// emulate the standard InvokeNotify() call.
void BeginInvokeNotify(uint32 kind = B_CONTROL_INVOKED);
void EndInvokeNotify();
// Private or reserved ---------------------------------------------------------
private:
// to be able to keep binary compatibility
virtual void _ReservedInvoker1();
virtual void _ReservedInvoker2();
virtual void _ReservedInvoker3();
BInvoker(const BInvoker&);
BInvoker &operator=(const BInvoker&);
BMessage *fMessage;
BMessenger fMessenger;
BHandler *fReplyTo;
bigtime_t fTimeout;
uint32 fNotifyKind;
uint32 _reserved[2]; // to be able to keep binary compatibility
};
//------------------------------------------------------------------------------
#endif // _INVOKER_H
/*
* $Log $
*
* $Id $
*
*/
+237
View File
@@ -0,0 +1,237 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Looper.h
// Author(s): Erik Jaesler ([email protected])
// DarkWyrm ([email protected])
// Description: BLooper class spawns a thread that runs a message loop.
//------------------------------------------------------------------------------
#ifndef _LOOPER_H
#define _LOOPER_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <Handler.h>
#include <List.h>
#include <OS.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class BMessage;
class BMessageQueue;
struct _loop_data_;
// Port (Message Queue) Capacity -----------------------------------------------
#define B_LOOPER_PORT_DEFAULT_CAPACITY 100
// BLooper class ---------------------------------------------------------------
class BLooper : public BHandler {
public:
BLooper(const char* name = NULL,
int32 priority = B_NORMAL_PRIORITY,
int32 port_capacity = B_LOOPER_PORT_DEFAULT_CAPACITY);
virtual ~BLooper();
// Archiving
BLooper(BMessage* data);
static BArchivable* Instantiate(BMessage* data);
virtual status_t Archive(BMessage* data, bool deep = true) const;
// Message transmission
status_t PostMessage(uint32 command);
status_t PostMessage(BMessage* message);
status_t PostMessage(uint32 command,
BHandler* handler,
BHandler* reply_to = NULL);
status_t PostMessage(BMessage* message,
BHandler* handler,
BHandler* reply_to = NULL);
virtual void DispatchMessage(BMessage* message, BHandler* handler);
virtual void MessageReceived(BMessage* msg);
BMessage* CurrentMessage() const;
BMessage* DetachCurrentMessage();
BMessageQueue* MessageQueue() const;
bool IsMessageWaiting() const;
// Message handlers
void AddHandler(BHandler* handler);
bool RemoveHandler(BHandler* handler);
int32 CountHandlers() const;
BHandler* HandlerAt(int32 index) const;
int32 IndexOf(BHandler* handler) const;
BHandler* PreferredHandler() const;
void SetPreferredHandler(BHandler* handler);
// Loop control
virtual thread_id Run();
virtual void Quit();
virtual bool QuitRequested();
bool Lock();
void Unlock();
bool IsLocked() const;
status_t LockWithTimeout(bigtime_t timeout);
thread_id Thread() const;
team_id Team() const;
static BLooper* LooperForThread(thread_id tid);
// Loop debugging
thread_id LockingThread() const;
int32 CountLocks() const;
int32 CountLockRequests() const;
sem_id Sem() const;
// Scripting
virtual BHandler* ResolveSpecifier(BMessage* msg,
int32 index,
BMessage* specifier,
int32 form,
const char* property);
virtual status_t GetSupportedSuites(BMessage* data);
// Message filters (also see BHandler).
virtual void AddCommonFilter(BMessageFilter* filter);
virtual bool RemoveCommonFilter(BMessageFilter* filter);
virtual void SetCommonFilterList(BList* filters);
BList* CommonFilterList() const;
// Private or reserved ---------------------------------------------------------
virtual status_t Perform(perform_code d, void* arg);
protected:
// called from overridden task_looper
BMessage* MessageFromPort(bigtime_t = B_INFINITE_TIMEOUT);
private:
typedef BHandler _inherited;
friend class BWindow;
friend class BApplication;
friend class BMessenger;
friend class BView;
friend class BHandler;
friend port_id _get_looper_port_(const BLooper* );
friend status_t _safe_get_server_token_(const BLooper* , int32* );
friend team_id _find_cur_team_id_();
virtual void _ReservedLooper1();
virtual void _ReservedLooper2();
virtual void _ReservedLooper3();
virtual void _ReservedLooper4();
virtual void _ReservedLooper5();
virtual void _ReservedLooper6();
BLooper(const BLooper&);
BLooper& operator=(const BLooper&);
BLooper(int32 priority, port_id port, const char* name);
status_t _PostMessage(BMessage* msg,
BHandler* handler,
BHandler* reply_to);
static status_t _Lock(BLooper* loop,
port_id port,
bigtime_t timeout);
static status_t _LockComplete(BLooper* loop,
int32 old,
thread_id this_tid,
sem_id sem,
bigtime_t timeout);
void InitData();
void InitData(const char* name, int32 prio, int32 capacity);
void AddMessage(BMessage* msg);
void _AddMessagePriv(BMessage* msg);
static status_t _task0_(void* arg);
void* ReadRawFromPort(int32* code,
bigtime_t tout = B_INFINITE_TIMEOUT);
BMessage* ReadMessageFromPort(bigtime_t tout = B_INFINITE_TIMEOUT);
virtual BMessage* ConvertToMessage(void* raw, int32 code);
virtual void task_looper();
void do_quit_requested(BMessage* msg);
bool AssertLocked() const;
BHandler* top_level_filter(BMessage* msg, BHandler* t);
BHandler* handler_only_filter(BMessage* msg, BHandler* t);
BHandler* apply_filters( BList* list,
BMessage* msg,
BHandler* target);
void check_lock();
BHandler* resolve_specifier(BHandler* target, BMessage* msg);
void UnlockFully();
static uint32 sLooperID;
static uint32 sLooperListSize;
static uint32 sLooperCount;
static _loop_data_* sLooperList;
static BLocker sLooperListLock;
static team_id sTeamID;
static void AddLooper(BLooper* l);
static bool IsLooperValid(const BLooper* l);
static void RemoveLooper(BLooper* l);
static void GetLooperList(BList* list);
static BLooper* LooperForName(const char* name);
static BLooper* LooperForPort(port_id port);
uint32 fLooperID;
BMessageQueue* fQueue;
BMessage* fLastMessage;
port_id fMsgPort;
long fAtomicCount;
sem_id fLockSem;
long fOwnerCount;
thread_id fOwner;
thread_id fTaskID;
uint32 _unused1;
int32 fInitPriority;
BHandler* fPreferred;
BList fHandlers;
BList* fCommonFilters;
bool fTerminating;
bool fRunCalled;
thread_id fCachedPid;
size_t fCachedStack;
void* fMsgBuffer;
size_t fMsgBufferSize;
uint32 _reserved[6];
};
//------------------------------------------------------------------------------
#endif // _LOOPER_H
/*
* $Log $
*
* $Id $
*
*/
+126
View File
@@ -0,0 +1,126 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: MessageFilter.h
// Author: Erik Jaesler ([email protected])
// Description: BMessageFilter class creates objects that filter
// in-coming BMessages.
//------------------------------------------------------------------------------
#ifndef _MESSAGE_FILTER_H
#define _MESSAGE_FILTER_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <Handler.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class BMessage;
// filter_hook Return Codes and Protocol ---------------------------------------
enum filter_result {
B_SKIP_MESSAGE,
B_DISPATCH_MESSAGE
};
typedef filter_result (*filter_hook)
(BMessage* message, BHandler** target, BMessageFilter* filter);
// BMessageFilter invocation criteria ------------------------------------------
enum message_delivery {
B_ANY_DELIVERY,
B_DROPPED_DELIVERY,
B_PROGRAMMED_DELIVERY
};
enum message_source {
B_ANY_SOURCE,
B_REMOTE_SOURCE,
B_LOCAL_SOURCE
};
// BMessageFilter Class --------------------------------------------------------
class BMessageFilter {
public:
BMessageFilter( uint32 what,
filter_hook func = NULL);
BMessageFilter( message_delivery delivery,
message_source source,
filter_hook func = NULL);
BMessageFilter( message_delivery delivery,
message_source source,
uint32 what,
filter_hook func = NULL);
BMessageFilter(const BMessageFilter& filter);
BMessageFilter(const BMessageFilter* filter);
virtual ~BMessageFilter();
BMessageFilter &operator=(const BMessageFilter& from);
// Hook function; ignored if filter_hook is non-NULL
virtual filter_result Filter(BMessage* message, BHandler** target);
message_delivery MessageDelivery() const;
message_source MessageSource() const;
uint32 Command() const;
bool FiltersAnyCommand() const;
BLooper *Looper() const;
// Private or reserved ---------------------------------------------------------
private:
friend class BLooper;
friend class BHandler;
virtual void _ReservedMessageFilter1();
virtual void _ReservedMessageFilter2();
void SetLooper(BLooper* owner);
filter_hook FilterFunction() const;
bool fFiltersAny;
uint32 what;
message_delivery fDelivery;
message_source fSource;
BLooper *fLooper;
filter_hook fFilterFunction;
uint32 _reserved[3];
};
//------------------------------------------------------------------------------
#endif // _MESSAGE_FILTER_H
/*
* $Log $
*
* $Id $
*
*/
+67
View File
@@ -0,0 +1,67 @@
//
// $Id: MessageQueue.h,v 1.1 2002/07/09 12:24:32 ejakowatz Exp $
//
// This is the BMessageQueue interface for OpenBeOS. It has been created
// to be source and binary compatible with the BeOS version of
// BMessageQueue.
//
#ifndef _OPENBEOS_MESSAGEQUEUE_H
#define _OPENBEOS_MESSAGEQUEUE_H
#include "Locker.h"
class BMessage;
#ifdef USE_OPENBEOS_NAMESPACE
namespace OpenBeOS {
#endif
class BMessageQueue {
public:
BMessageQueue();
virtual ~BMessageQueue();
void AddMessage(BMessage *message);
void RemoveMessage(BMessage *message);
int32 CountMessages(void) const;
bool IsEmpty(void) const;
BMessage *FindMessage(int32 index) const;
BMessage *FindMessage(uint32 what, int32 index=0) const;
bool Lock(void);
void Unlock(void);
bool IsLocked(void);
BMessage *NextMessage(void);
private:
// Reserved space in the vtable for future changes to BMessageQueue
virtual void _ReservedMessageQueue1(void);
virtual void _ReservedMessageQueue2(void);
virtual void _ReservedMessageQueue3(void);
BMessageQueue(const BMessageQueue &);
BMessageQueue &operator=(const BMessageQueue &);
BMessage *fTheQueue;
BMessage *fQueueTail;
int32 fMessageCount;
BLocker fLocker;
// Reserved space for future changes to BMessageQueue
uint32 fReservedSpace[3];
};
#ifdef USE_OPENBEOS_NAMESPACE
}
#endif
#endif // _OPENBEOS_MESSAGEQUEUE_H
+62
View File
@@ -0,0 +1,62 @@
/******************************************************************************
/
/ File: MessageRunner.h
/
/ Description:
/
/ Copyright 1998, Be Incorporated, All Rights Reserved.
/
*******************************************************************************/
#ifndef _MESSAGE_RUNNER_H
#define _MESSAGE_RUNNER_H
#include <BeBuild.h>
#include <Messenger.h>
/*----------------------------------------------------------------------*/
/*----- BMessageRunner class --------------------------------------------*/
class BMessageRunner {
public:
BMessageRunner(BMessenger target, const BMessage *msg,
bigtime_t interval, int32 count = -1);
BMessageRunner(BMessenger target, const BMessage *msg,
bigtime_t interval, int32 count, BMessenger reply_to);
virtual ~BMessageRunner();
status_t InitCheck() const;
status_t SetInterval(bigtime_t interval);
status_t SetCount(int32 count);
status_t GetInfo(bigtime_t *interval, int32 *count) const;
/*----- Private or reserved -----------------------------------------*/
private:
virtual void _ReservedMessageRunner1();
virtual void _ReservedMessageRunner2();
virtual void _ReservedMessageRunner3();
virtual void _ReservedMessageRunner4();
virtual void _ReservedMessageRunner5();
virtual void _ReservedMessageRunner6();
BMessageRunner(const BMessageRunner &);
BMessageRunner &operator=(const BMessageRunner &);
void InitData(BMessenger target, const BMessage *msg,
bigtime_t interval, int32 count, BMessenger reply_to);
status_t SetParams(bool reset_i, bigtime_t interval,
bool reset_c, int32 count);
int32 fToken;
uint32 _reserved[6];
};
/*-------------------------------------------------------------*/
/*-------------------------------------------------------------*/
#endif /* _MESSAGE_QUEUE_H */
+116
View File
@@ -0,0 +1,116 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Messenger.h
// Author: Ingo Weinhold ([email protected])
// Description: BMessenger delivers messages to local or remote targets.
//------------------------------------------------------------------------------
#ifndef _MESSENGER_H
#define _MESSENGER_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <OS.h>
#include <ByteOrder.h>
#include <Message.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class BHandler;
class BLooper;
// BMessenger class ------------------------------------------------------------
class BMessenger {
public:
BMessenger();
BMessenger(const char *signature, team_id team = -1,
status_t *result = NULL);
BMessenger(const BHandler *handler, const BLooper *looper = NULL,
status_t *result = NULL);
BMessenger(const BMessenger &from);
~BMessenger();
// Target
bool IsTargetLocal() const;
BHandler *Target(BLooper **looper) const;
bool LockTarget() const;
status_t LockTargetWithTimeout(bigtime_t timeout) const;
// Message sending
status_t SendMessage(uint32 command, BHandler *replyTo = NULL) const;
status_t SendMessage(BMessage *message, BHandler *replyTo = NULL,
bigtime_t timeout = B_INFINITE_TIMEOUT) const;
status_t SendMessage(BMessage *message, BMessenger replyTo,
bigtime_t timeout = B_INFINITE_TIMEOUT) const;
status_t SendMessage(uint32 command, BMessage *reply) const;
status_t SendMessage(BMessage *message, BMessage *reply,
bigtime_t deliveryTimeout = B_INFINITE_TIMEOUT,
bigtime_t replyTimeout = B_INFINITE_TIMEOUT) const;
// Operators and misc
BMessenger &operator=(const BMessenger &from);
bool operator==(const BMessenger &other) const;
bool IsValid() const;
team_id Team() const;
//----- Private or reserved -----------------------------------------
private:
friend class BRoster;
friend class _TRoster_;
friend class BMessage;
friend inline void _set_message_reply_(BMessage *, BMessenger);
friend status_t swap_data(type_code, void *, size_t, swap_action);
friend bool operator<(const BMessenger &a, const BMessenger &b);
friend bool operator!=(const BMessenger &a, const BMessenger &b);
BMessenger(team_id team, port_id port, int32 token, bool preferred);
void InitData(const char *signature, team_id team, status_t *result);
private:
port_id fPort;
int32 fHandlerToken;
team_id fTeam;
int32 extra0;
int32 extra1;
bool fPreferredTarget;
bool extra2;
bool extra3;
bool extra4;
};
_IMPEXP_BE bool operator<(const BMessenger &a, const BMessenger &b);
_IMPEXP_BE bool operator!=(const BMessenger &a, const BMessenger &b);
#endif // _MESSENGER_H
+134
View File
@@ -0,0 +1,134 @@
/*******************************************************************************
/
/ File: PropertyInfo.h
/
/ Description: Utility class for maintain scripting information
/
/ Copyright 1997-98, Be Incorporated, All Rights Reserved
/
*******************************************************************************/
#ifndef _PROPERTY_INFO_H
#define _PROPERTY_INFO_H
#include <BeBuild.h>
#include <SupportDefs.h>
#include <Flattenable.h>
#include <TypeConstants.h> /* For convenience */
/*----------------------------------------------------------------*/
/*----- the property_info structure ------------------------------*/
struct _oproperty_info_;
struct compound_type {
struct field_pair {
char *name; // name of entry in message
type_code type; // type_code of entry in message
};
field_pair pairs[5];
};
struct property_info {
char *name;
uint32 commands[10];
uint32 specifiers[10];
char *usage;
uint32 extra_data;
uint32 types[10];
compound_type ctypes[3];
uint32 _reserved[10];
};
enum value_kind {
B_COMMAND_KIND = 0,
B_TYPE_CODE_KIND = 1
};
struct value_info {
char *name;
uint32 value;
value_kind kind;
char *usage;
uint32 extra_data;
uint32 _reserved[10];
};
#define B_PROPERTY_INFO_TYPE 'SCTD'
/*----------------------------------------------------------------*/
/*----- BPropertyInfo class --------------------------------------*/
class BPropertyInfo : public BFlattenable {
public:
BPropertyInfo(property_info *p = NULL,
value_info *ci = NULL,
bool free_on_delete = false);
virtual ~BPropertyInfo();
virtual int32 FindMatch(BMessage *msg,
int32 index,
BMessage *spec,
int32 form,
const char *prop,
void *data = NULL) const;
virtual bool IsFixedSize() const;
virtual type_code TypeCode() const;
virtual ssize_t FlattenedSize() const;
virtual status_t Flatten(void *buffer, ssize_t size) const;
virtual bool AllowsTypeCode(type_code code) const;
virtual status_t Unflatten(type_code c,
const void *buf,
ssize_t s);
const property_info *Properties() const;
const value_info *Values() const;
int32 CountProperties() const;
int32 CountValues() const;
void PrintToStream() const;
/*----- Private or reserved -----------------------------------------*/
protected:
static bool FindCommand(uint32, int32, property_info *);
static bool FindSpecifier(uint32, property_info *);
private:
virtual void _ReservedPropertyInfo1();
virtual void _ReservedPropertyInfo2();
virtual void _ReservedPropertyInfo3();
virtual void _ReservedPropertyInfo4();
BPropertyInfo(const BPropertyInfo &);
BPropertyInfo &operator=(const BPropertyInfo &);
void FreeMem();
void FreeInfoArray(property_info *p, int32);
void FreeInfoArray(value_info *p, int32);
void FreeInfoArray(_oproperty_info_ *p, int32);
static property_info *ConvertToNew(const _oproperty_info_ *p);
static _oproperty_info_ *ConvertFromNew(const property_info *p);
property_info *fPropInfo;
value_info *fValueInfo;
int32 fPropCount;
bool fInHeap;
bool fOldInHeap;
uint16 fValueCount;
_oproperty_info_ *fOldPropInfo;
uint32 _reserved[2]; /* was 4 */
/* Deprecated */
private:
const property_info *PropertyInfo() const;
BPropertyInfo(property_info *p,
bool free_on_delete);
static bool MatchCommand(uint32, int32, property_info *);
static bool MatchSpecifier(uint32, property_info *);
};
/*-------------------------------------------------------------*/
/*-------------------------------------------------------------*/
#endif /* _PROPERTY_INFO_H */
+227
View File
@@ -0,0 +1,227 @@
/******************************************************************************
/
/ File: Roster.h
/
/ Description: BRoster class lets you launch apps and keeps
/ track of apps that are running.
/ Global be_roster represents the default BRoster.
/ app_info structure provides info for a running app.
/
/ Copyright 1995-98, Be Incorporated, All Rights Reserved.
/
******************************************************************************/
#ifndef _ROSTER_H
#define _ROSTER_H
#include <BeBuild.h>
#include <Messenger.h>
#include <Mime.h>
#include <Clipboard.h>
class BList;
class BMessage;
class BNodeInfo;
extern "C" int _init_roster_();
/*-------------------------------------------------------------*/
/* --------- app_info Struct and Values ------------------------ */
struct app_info {
app_info();
~app_info();
thread_id thread;
team_id team;
port_id port;
uint32 flags;
entry_ref ref;
char signature[B_MIME_TYPE_LENGTH];
};
#define B_LAUNCH_MASK (0x3)
#define B_SINGLE_LAUNCH (0x0)
#define B_MULTIPLE_LAUNCH (0x1)
#define B_EXCLUSIVE_LAUNCH (0x2)
#define B_BACKGROUND_APP (0x4)
#define B_ARGV_ONLY (0x8)
#define _B_APP_INFO_RESERVED1_ (0x10000000)
enum {
B_REQUEST_LAUNCHED = 0x00000001,
B_REQUEST_QUIT = 0x00000002,
B_REQUEST_ACTIVATED = 0x00000004
};
enum {
B_SOME_APP_LAUNCHED = 'BRAS',
B_SOME_APP_QUIT = 'BRAQ',
B_SOME_APP_ACTIVATED = 'BRAW'
};
/*-------------------------------------------------------------*/
/* --------- BRoster class----------------------------------- */
class BRoster {
public:
BRoster();
~BRoster();
/* Querying for apps */
bool IsRunning(const char *mime_sig) const;
bool IsRunning(entry_ref *ref) const;
team_id TeamFor(const char *mime_sig) const;
team_id TeamFor(entry_ref *ref) const;
void GetAppList(BList *team_id_list) const;
void GetAppList(const char *sig, BList *team_id_list) const;
status_t GetAppInfo(const char *sig, app_info *info) const;
status_t GetAppInfo(entry_ref *ref, app_info *info) const;
status_t GetRunningAppInfo(team_id team, app_info *info) const;
status_t GetActiveAppInfo(app_info *info) const;
status_t FindApp(const char *mime_type, entry_ref *app) const;
status_t FindApp(entry_ref *ref, entry_ref *app) const;
/* Launching, activating, and broadcasting to apps */
status_t Broadcast(BMessage *msg) const;
status_t Broadcast(BMessage *msg, BMessenger reply_to) const;
status_t StartWatching(BMessenger target,
uint32 event_mask = B_REQUEST_LAUNCHED | B_REQUEST_QUIT) const;
status_t StopWatching(BMessenger target) const;
status_t ActivateApp(team_id team) const;
status_t Launch(const char *mime_type, BMessage *initial_msgs = NULL,
team_id *app_team = NULL) const;
status_t Launch(const char *mime_type, BList *message_list,
team_id *app_team = NULL) const;
status_t Launch(const char *mime_type, int argc, char **args,
team_id *app_team = NULL) const;
status_t Launch(const entry_ref *ref, const BMessage *initial_message = NULL,
team_id *app_team = NULL) const;
status_t Launch(const entry_ref *ref, const BList *message_list,
team_id *app_team = NULL) const;
status_t Launch(const entry_ref *ref, int argc, const char * const *args,
team_id *app_team = NULL) const;
/* Recent document and app support */
void GetRecentDocuments(BMessage *refList, int32 maxCount,
const char *ofType = NULL,
const char *openedByAppSig = NULL) const;
void GetRecentDocuments(BMessage *refList, int32 maxCount,
const char *ofTypeList[], int32 ofTypeListCount,
const char *openedByAppSig = NULL) const;
void GetRecentFolders(BMessage *refList, int32 maxCount,
const char *openedByAppSig = NULL) const;
void GetRecentApps(BMessage *refList, int32 maxCount) const;
void AddToRecentDocuments(const entry_ref *doc,
const char *appSig = NULL) const;
void AddToRecentFolders(const entry_ref *folder,
const char *appSig = NULL) const;
/*----- Private or reserved ------------------------------*/
private:
friend class BApplication;
friend class BWindow;
friend class _BAppCleanup_;
friend int _init_roster_();
friend status_t _send_to_roster_(BMessage *, BMessage *, bool);
friend bool _is_valid_roster_mess_(bool);
friend status_t BMimeType::StartWatching(BMessenger);
friend status_t BMimeType::StopWatching(BMessenger);
friend status_t BClipboard::StartWatching(BMessenger);
friend status_t BClipboard::StopWatching(BMessenger);
enum mtarget {
MAIN_MESSENGER,
MIME_MESSENGER,
USE_GIVEN
};
status_t _StartWatching(mtarget t, BMessenger *roster_mess, uint32 what,
BMessenger notify, uint32 event_mask) const;
status_t _StopWatching(mtarget t, BMessenger *roster_mess, uint32 what,
BMessenger notify) const;
uint32 AddApplication( const char *mime_sig,
entry_ref *ref,
uint32 flags,
team_id team,
thread_id thread,
port_id port,
bool full_reg) const;
void SetSignature(team_id team, const char *mime_sig) const;
void SetThread(team_id team, thread_id tid) const;
void SetThreadAndTeam(uint32 entry_token,
thread_id tid,
team_id team) const;
void CompleteRegistration(team_id team,
thread_id,
port_id port) const;
bool IsAppPreRegistered( entry_ref *ref,
team_id team,
app_info *info) const;
void RemovePreRegApp(uint32 entry_token) const;
void RemoveApp(team_id team) const;
status_t xLaunchAppPrivate( const char *mime_sig,
const entry_ref *ref,
BList* msg_list,
int cargs,
char **args,
team_id *app_team) const;
bool UpdateActiveApp(team_id team) const;
void SetAppFlags(team_id team, uint32 flags) const;
void DumpRoster() const;
status_t resolve_app(const char *in_type,
const entry_ref *ref,
entry_ref *app_ref,
char *app_sig,
uint32 *app_flags,
bool *was_document) const;
status_t translate_ref(const entry_ref *ref,
BMimeType *app_meta,
entry_ref *app_ref,
BFile *app_file,
char *app_sig,
bool *was_document) const;
status_t translate_type(const char *mime_type,
BMimeType *meta,
entry_ref *app_ref,
BFile *app_file,
char *app_sig) const;
status_t sniff_file(const entry_ref *file,
BNodeInfo *finfo,
char *mime_type) const;
bool is_wildcard(const char *sig) const;
status_t get_unique_supporting_app(const BMessage *apps,
char *out_sig) const;
status_t get_random_supporting_app(const BMessage *apps,
char *out_sig) const;
char **build_arg_vector(char **args, int *pargs,
const entry_ref *app_ref,
const entry_ref *doc_ref) const;
status_t send_to_running(team_id tema,
const entry_ref *app_ref,
int cargs, char **args,
const BList *msg_list,
const entry_ref *ref) const;
void InitMessengers();
BMessenger fMess;
BMessenger fMimeMess;
uint32 _fReserved[3];
};
/*-----------------------------------------------------*/
/*----- Global be_roster ------------------------------*/
extern _IMPEXP_BE const BRoster *be_roster;
/*-----------------------------------------------------*/
/*-----------------------------------------------------*/
#endif /* _ROSTER_H */
+138
View File
@@ -0,0 +1,138 @@
/*****************************************************************************/
// DirectWindow.h
//
// A "client window class for direct screen access."
//
//
// Copyright (c) 2001 OpenBeOS Project
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
/*****************************************************************************/
#ifndef GAME_KIT_DIRECT_WINDOW
#define GAME_KIT_DIRECT_WINDOW
#include <Region.h>
#include <Window.h>
class BDirectDriver;
// State of the direct access when called back through DirectConnected.
enum direct_buffer_state
{
B_DIRECT_MODE_MASK = 15,
B_DIRECT_START = 0,
B_DIRECT_STOP = 1,
B_DIRECT_MODIFY = 2,
B_CLIPPING_MODIFIED = 16,
B_BUFFER_RESIZED = 32,
B_BUFFER_MOVED = 64,
B_BUFFER_RESET = 128
};
// State of the direct driver and its hooks functions.
enum direct_driver_state
{
B_DRIVER_CHANGED = 0x0001,
B_MODE_CHANGED = 0x0002
};
// Frame buffer access descriptor.
typedef struct
{
direct_buffer_state buffer_state;
direct_driver_state driver_state;
void *bits;
void *pci_bits;
int32 bytes_per_row;
uint32 bits_per_pixel;
color_space pixel_format;
buffer_layout layout;
buffer_orientation orientation;
uint32 _reserved[9];
uint32 _dd_type_;
uint32 _dd_token_;
uint32 clip_list_count;
clipping_rect window_bounds;
clipping_rect clip_bounds;
clipping_rect clip_list[1];
} direct_buffer_info;
class BDirectWindow : public BWindow
{
public:
// Construction and destruction.
BDirectWindow( BRect frame, const char* pTitle, window_type type,
uint32 flags, uint32 workspace = B_CURRENT_WORKSPACE );
BDirectWindow( BRect frame, const char* pTitle, window_look look,
window_feel feel, uint32 flags, uint32 workspace = B_CURRENT_WORKSPACE );
virtual ~BDirectWindow();
// Save and restore.
static BArchivable* Instantiate( BMessage* pData );
virtual status_t Archive( BMessage *data, bool deep = true ) const;
virtual void DirectConnected( direct_buffer_info* pInfo );
status_t GetClippingRegion( BRegion* pRegion, BPoint* pOrigin = NULL ) const;
status_t SetFullScreen( bool enable );
bool IsFullScreen() const;
static bool SupportsWindowMode( screen_id = B_MAIN_SCREEN_ID );
// Defined for future extension (fragile base class). Otherwise
// identical to BWindow.
virtual void Quit();
virtual void DispatchMessage( BMessage* pMessage, BHandler* pHandler );
virtual void MessageReceived( BMessage* pMessage );
virtual void FrameMoved( BPoint new_position );
virtual void WorkspacesChanged( uint32 old_workspace, uint32 new_workspace );
virtual void WorkspaceActivated( int32 workspace, bool state );
virtual void FrameResized( float new_width, float new_height );
virtual void Minimize( bool minimize );
virtual void Zoom( BPoint rec_position, float rec_width, float rec_height );
virtual void ScreenChanged( BRect screen_size, color_space depth );
virtual void MenusBeginning();
virtual void MenusEnded();
virtual void WindowActivated( bool state );
virtual void Show();
virtual void Hide();
virtual status_t GetSupportedSuites( BMessage* pData );
virtual status_t Perform( perform_code performCode, void* pArg );
virtual BHandler * ResolveSpecifier( BMessage* pMsg, int32 index,
BMessage* pSpecifier, int32 form, const char* pProperty );
private:
// No copying allowed.
BDirectWindow();
BDirectWindow( BDirectWindow& );
BDirectWindow& operator=( BDirectWindow& );
private:
// Fill in all the particulars relating to our implementation,
// once we know what they're going to be, here.
}
#endif // GAME_KIT_DIRECT_WINDOW
+80
View File
@@ -0,0 +1,80 @@
/*****************************************************************************/
// FileGameSound.h
//
// This is "a class that streams data out of a file."
//
//
// Copyright (c) 2001 OpenBeOS Project
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
/*****************************************************************************/
#ifndef GAME_KIT_FILE_GAME_SOUND
#define GAME_KIT_FILE_GAME_SOUND
#include <StreamingGameSound.h>
class BMediaFile;
namespace BPrivate
{
class BTrackReader;
}
class BFileGameSound : public BStreamingGameSound
{
public:
BFileGameSound( const entry_ref* pFile, bool looping = true,
BGameSoundDevice* pDevice = NULL );
BFileGameSound( const char* pFilename, bool looping = true,
BGameSoundDevice* pDevice = NULL );
virtual ~BFileGameSound();
virtual BGameSound* Clone() const;
virtual status_t StartPlaying();
virtual status_t StopPlaying();
// Use this if you have stopped and want to start again quickly.
status_t Preload();
virtual void FillBuffer( void* pInBuffer, size_t inByteCount );
virtual status_t Perform( int32 selector, void* pData );
virtual status_t SetPaused( bool isPaused, bigtime_t rampTime );
enum
{
B_NOT_PAUSED,
B_PAUSE_IN_PROGRESS,
B_PAUSED
};
int32 IsPaused();
private:
// Leave these declarations private unless you plan on actually
// implementing and using them.
BFileGameSound();
BFileGameSound( const BFileGameSound& );
BFileGameSound& operator=( const BFileGameSound& );
};
#endif // GAME_KIT_FILE_GAME_SOUND
+35
View File
@@ -0,0 +1,35 @@
/*****************************************************************************/
// GameKit.h
//
// Includes headers for all classes that comprise the GameKit.
//
//
// Copyright (c) 2001 OpenBeOS Project
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
/*****************************************************************************/
#include <DirectWindow.h>
#include <FileGameSound.h>
#include <GameSound.h>
#include <GameSoundDefs.h>
#include <PushGameSound.h>
#include <SimpleGameSound.h>
#include <StreamingGameSound.h>
#include <WindowScreen.h>
+98
View File
@@ -0,0 +1,98 @@
/*****************************************************************************/
// GameSound.h
//
// This is an abstract base class for "all sounds being played using the
// gamesound kit. Use one of the concrete subclasses for actually playing
// sound."
//
//
// Copyright (c) 2001 OpenBeOS Project
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
/*****************************************************************************/
#ifndef GAME_KIT_GAME_SOUND
#define GAME_KIT_GAME_SOUND
#include <GameSoundDefs.h>
#include <new>
struct gs_audio_format;
class BGameSoundDevice;
class BGameSound
{
public:
BGameSound( BGameSoundDevice* pDevice = NULL );
virtual ~BGameSound();
virtual BGameSound* Clone() const = 0;
status_t InitCheck() const;
BGameSoundDevice* Device() const;
gs_id ID() const;
// Only valid after Init().
const gs_audio_format& Format() const;
virtual status_t StartPlaying();
virtual bool IsPlaying();
virtual status_t StopPlaying();
// Ramp duration is in seconds.
status_t SetGain( float gain, bigtime_t duration = 0 );
status_t SetPan( float pan, bigtime_t duration = 0 );
float Gain();
float Pan();
virtual status_t SetAttributes( gs_attribute* pInAttributes,
size_t inAttributeCount );
virtual status_t GetAttributes( gs_attribute* pOutAttributes,
size_t outAttributeCount );
virtual status_t Perform( int32 selector, void * data );
void* operator new( size_t size );
void* operator new( size_t size, const nothrow_t& ) throw();
void operator delete( void* ptr );
void operator delete( void* ptr, const nothrow_t& ) throw();
// These were implemented in BPrivGameSound, presumably
// for reasons of privacy. If that's the only reason, then
// we can put them here, because you've got the source, my man.
// Otherwise, we'll put 'em where they have to be.
static status_t SetMemoryPoolSize( size_t in_poolSize );
static status_t LockMemoryPool( bool in_lockInCore );
static int32 SetMaxSoundCount( int32 in_maxCount );
protected:
status_t SetInitError( status_t in_initError );
status_t Init( gs_id handle );
BGameSound( const BGameSound& other );
BGameSound& operator=( const BGameSound & other );
private:
BGameSound();
// Our implementation details go here.
};
#endif // GAME_KIT_GAME_SOUND
+103
View File
@@ -0,0 +1,103 @@
/*****************************************************************************/
// GameSoundDefs.h
//
// "Definitions of common types and constants for the gamesound kit."
//
//
// Copyright (c) 2001 OpenBeOS Project
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
/*****************************************************************************/
#ifndef GAME_KIT_GAME_SOUND_DEFS
#define GAME_KIT_GAME_SOUND_DEFS
#include <SupportDefs.h>
#define B_GS_CUR_API_VERSION B_BEOS_VERSION
#define B_GS_MIN_API_VERSION 0x100
typedef int32 gs_id;
// Invalid sound handle.
#define B_GS_INVALID_SOUND ((gs_id)-1)
// gs_id for the main mix buffer.
#define B_GS_MAIN_SOUND ((gs_id)-2)
// FIXME - renumber to real error messages.
enum
{
B_GS_BAD_HANDLE = -99999,
B_GS_NO_SOUNDS,
B_GS_NO_HARDWARE,
B_GS_ALREADY_COMMITTED,
B_GS_READ_ONLY_VALUE
};
struct gs_audio_format
{
// Same as media_raw_audio_format.
enum format
{
B_GS_U8 = 0x11, // 128 == mid, 1 == bottom, 255 == top.
B_GS_S16 = 0x2, // 0 == mid, -32767 == bottom, +32767 == top.
B_GS_F = 0x24, // 0 == mid, -1.0 == bottom, 1.0 == top.
B_GS_S32 = 0x4 // 0 == mid, 0x80000001 == bottom, 0x7fffffff == top.
};
float frame_rate;
uint32 channel_count; // 1 or 2, mostly.
uint32 format; // For compressed formats, go to media_encoded_audio_format.
uint32 byte_order; // 2 for little endian, 1 for big endian.
size_t buffer_size; // Size of each buffer -- NOT GUARANTEED.
};
enum gs_attributes
{
B_GS_NO_ATTRIBUTE = 0, // When there is no attribute.
B_GS_MAIN_GAIN = 1, // 0 == 0 dB, -6.0 == -6 dB (gs_id ignored).
B_GS_CD_THROUGH_GAIN, // 0 == 0 dB, -12.0 == -12 dB (gs_id ignored).
// But which CD?
B_GS_GAIN = 128, // 0 == 0 dB, -1.0 == -1 dB, +10.0 == +10 dB.
B_GS_PAN, // 0 == middle, -1.0 == left, +1.0 == right.
B_GS_SAMPLING_RATE, // 44100.0 == 44.1 kHz.
B_GS_LOOPING, // 0 == no.
B_GS_FIRST_PRIVATE_ATTRIBUTE = 90000,
B_GS_FIRST_USER_ATTRIBUTE = 100000
};
struct gs_attribute
{
int32 attribute; // Which attribute.
bigtime_t duration; // How long of time to ramp over for the change.
float value; // Where the value stops changing.
uint32 flags; // Whatever flags are for the attribute.
};
struct gs_attribute_info
{
int32 attribute;
float granularity;
float minimum;
float maximum;
};
#endif // GAME_KIT_GAME_SOUND_DEFS
+87
View File
@@ -0,0 +1,87 @@
/*****************************************************************************/
// PushGameSound.h
//
// This is "a class for games that want to push data at the system,
// rather than have a callback get called."
//
//
// Copyright (c) 2001 OpenBeOS Project
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
/*****************************************************************************/
#ifndef GAME_KIT_PUSH_GAME_SOUND
#define GAME_KIT_PUSH_GAME_SOUND
#include <StreamingGameSound.h>
class BPushGameSound : public BStreamingGameSound
{
public:
BPushGameSound( size_t inBufferFrameCount,
const gs_audio_format* pFormat, size_t inBufferCount = 2,
BGameSoundDevice* pDevice = NULL );
virtual ~BPushGameSound();
enum lock_status
{
lock_failed = -1, // not yet time to do more
lock_ok = 0, // do more
lock_ok_frames_dropped // you may have missed some buffers
};
virtual lock_status LockNextPage( void** ppOut_pagePtr,
size_t* pOut_pageSize );
virtual status_t UnlockPage( void* pIn_pagePtr );
virtual lock_status LockForCyclic( void** ppOut_basePtr,
size_t* pOut_size );
virtual status_t UnlockCyclic();
virtual size_t CurrentPosition();
virtual BGameSound* Clone() const;
virtual status_t Perform( int32 selector, void* pData );
protected:
// Will allocate handle and call Init().
virtual status_t SetParameters( size_t inBufferFrameCount,
const gs_audio_format* pFormat, size_t inBufferCount );
virtual status_t SetStreamHook(
void (*hook)( void* pInCookie, void* pInBuffer, size_t inByteCount, BStreamingGameSound* pMe ),
void* pCookie );
// Default is to call stream hook, if any.
virtual void FillBuffer( void* pInBuffer, size_t inByteCount );
private:
// Leave these declarations private unless you plan on actually
// implementing and using them.
BPushGameSound();
BPushGameSound( const BPushGameSound& );
BPushGameSound& operator=( const BPushGameSound& );
};
#endif // GAME_KIT_PUSH_GAME_SOUND
+64
View File
@@ -0,0 +1,64 @@
/*****************************************************************************/
// SimpleGameSound.h
//
// This is "a class for sound effects that are short, and consist of
// non-changing samples in memory."
//
//
// Copyright (c) 2001 OpenBeOS Project
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
/*****************************************************************************/
#ifndef GAME_KIT_SIMPLE_GAME_SOUND
#define GAME_KIT_SIMPLE_GAME_SOUND
#include <GameSound.h>
class BSimpleGameSound : public BGameSound
{
public:
BSimpleGameSound( const entry_ref* pInFile,
BGameSoundDevice* pDevice = NULL );
BSimpleGameSound( const char* pInFile,
BGameSoundDevice* pDevice = NULL );
BSimpleGameSound( const void* pInData,
size_t inFrameCount, const gs_audio_format* pFormat,
BGameSoundDevice* pDevice = NULL );
BSimpleGameSound( const BSimpleGameSound& other );
virtual ~BSimpleGameSound();
virtual BGameSound* Clone() const;
virtual status_t Perform( int32 selector, void* pData );
status_t SetIsLooping( bool looping );
bool IsLooping() const;
private:
// Leave these declarations private unless you plan on actually
// implementing and using them.
BSimpleGameSound();
BSimpleGameSound& operator=( const BSimpleGameSound& );
};
#endif
+83
View File
@@ -0,0 +1,83 @@
/*****************************************************************************/
// StreamingGameSound.h
//
// This is "a class for all kinds of streaming (data not known beforehand)
// game sounds."
//
//
// Copyright (c) 2001 OpenBeOS Project
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
/*****************************************************************************/
#ifndef GAME_KIT_STREAMING_GAME_SOUND
#define GAME_KIT_STREAMING_GAME_SOUND
#include <SupportDefs.h>
#include <GameSound.h>
#include <Locker.h>
class BStreamingGameSound : public BGameSound
{
public:
BStreamingGameSound( size_t inBufferFrameCount,
const gs_audio_format* pFormat, size_t inBufferCount = 2,
BGameSoundDevice* pDevice = NULL );
virtual ~BStreamingGameSound();
virtual BGameSound* Clone() const;
virtual status_t SetStreamHook(
void (*hook)( void* pInCookie, void* pInBuffer, size_t inByteCount, BStreamingGameSound* pMe ),
void* pCookie );
// The default is to call stream hook, if any.
virtual void FillBuffer( void * inBuffer, size_t inByteCount );
virtual status_t SetAttributes( gs_attribute* inAttributes,
size_t inAttributeCount );
virtual status_t Perform( int32 selector, void* pData );
protected:
BStreamingGameSound( BGameSoundDevice* pDevice );
// Will allocate handle and call Init().
virtual status_t SetParameters( size_t inBufferFrameCount,
const gs_audio_format* pFormat, size_t inBufferCount );
bool Lock();
void Unlock();
private:
BLocker _m_lock;
static void stream_callback( void* pCookie, gs_id handle,
void* pBuffer, int32 offset, int32 size, size_t bufSize );
// Leave these declarations private unless you plan on actually
// implementing and using them.
BStreamingGameSound();
BStreamingGameSound( const BStreamingGameSound& );
BStreamingGameSound& operator=( const BStreamingGameSound& );
};
#endif // GAME_KIT_STREAMING_GAME_SOUND
+174
View File
@@ -0,0 +1,174 @@
/*****************************************************************************/
// WindowScreen.h
//
// This is a "client window class for direct screen access."
//
//
// Copyright (c) 2001 OpenBeOS Project
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
/*****************************************************************************/
#ifndef GAME_KIT_WINDOW_SCREEN
#define GAME_KIT_WINDOW_SCREEN
#include <kernel/image.h>
#include <Accelerant.h>
#include <BeBuild.h>
#include <GraphicsCard.h>
#include <OS.h>
#include <SupportDefs.h>
#include <Window.h>
// Private struct.
typedef struct
{
area_id memory_area;
area_id io_area;
char addon_path[64+B_FILE_NAME_LENGTH];
} _direct_screen_info_;
// Private typedef.
typedef int32 (*_add_on_control_)( uint32,void* );
// Global function, allowing to move the position of the mouse when
// the GameKit is in control of the screen.
_IMPEXP_GAME void set_mouse_position( int32 x, int32 y );
//********************* WARNING - WARNING - WARNING ***********************************
// This is the current version of WindowScreen. The main purpose of this object is to
// establish a direct connexion between application and graphic driver, to increase
// efficiency and abilities. The graphic driver architecture will overcome serious
// changes in the next release, consequently this could only be a preview version of
// the real WindowScreen API.
//
// Question - is what follows below still true?
// Answer - to be determined.
//
// "Nevertheless, compatibility will be insured in future releases FOR MOST OF THE API,
// through the use of a compatibility library (the new game library having a name
// different from "libgame.so"), or a compatibility class (the new WindowScreen class
// using a different name). Part of the API for which compatibility will not be insure
// after the Preview Release are specifically pointed out in the following declarations."
//***************************************************************************************
enum
{
B_ENABLE_VIEW_DRAWING = 0x0001,
B_ENABLE_DEBUGGER = 0x0002
};
class BWindowScreen : public BWindow
{
public:
BWindowScreen( const char* pTitle, uint32 space, status_t* pError,
bool debug_enable = false );
BWindowScreen( const char *pTitle, uint32 space, uint32 attributes,
status_t* pError );
virtual ~BWindowScreen();
virtual void Quit();
virtual void ScreenConnected( bool active );
void Disconnect();
virtual void WindowActivated( bool active );
virtual void WorkspaceActivated( int32 workspace, bool state );
virtual void ScreenChanged( BRect screen_size, color_space depth );
virtual void Hide();
virtual void Show();
void SetColorList( rgb_color* pList, int32 first_index = 0, int32 last_index = 255 );
status_t SetSpace( uint32 space );
bool CanControlFrameBuffer();
status_t SetFrameBuffer( int32 width, int32 height );
status_t MoveDisplayArea( int32 x, int32 y );
// IOBase will not be supported in a future compatibility version of
// WindowScreen. Its features should be replaced by other functions
// of the new API.
void *IOBase();
rgb_color* ColorList();
frame_buffer_info* FrameBufferInfo();
graphics_card_hook CardHookAt( int32 index );
graphics_card_info* CardInfo();
//******************************* Debugger API Notice ********************************
// Those three calls, and the debug_enable flag in the constructor, have been added to
// help debugging a WindowScreen application without a cross-developement platform or
// the use of serial debug output.
//
// To use them, you need to :
// - enable the debug mode by setting the debug_enable flag of the constructor to "true".
// - register all threads that could be accessing the screen directly at any time. To do
// that, call RegisterThread after spawning the new thread and before resuming
// it (you should never draw from the Window thread itself, neither register it).
// - launch your application from Terminal. The GameKit will first swicth to another
// workspace before opening the WindowScreen. If you launch from workspace 0 [Alt-F1],
// it will choose the workspace 1 [Alt-F2]. For any other workspace, it will choose
// the previous one (for example, for workspace 3 (Alt-F4), it will choose workspace 2
// [Alt-F3]).
//
// Then :
// - You can use printf(...) anywhere to display informations that will be logged in the
// Terminal window. You can go back to the Terminal Window at any time (using the
// correct Alt-F?? key). Switching workspace will automatically suspend all the thread
// you registered and save the graphic context. Switching back to the WindowScreen
// workspace will restore everything and resume your application.
// - If you need to save and restore more states when your application is suspended and
// resumed, you can overwrite the ForceSwitchForDebug() method. This function is called
// with active == true just after suspending your app, and active == false just before
// resuming it.
// - You can suspend your application by calling the Debugger() method. This will also
// switch to the Terminal workspace. Then you can resume by just switchng back to the
// WindowScreen workspace (using the good Alt-F?? key). It's better not to call Debugger()
// with the WindowScreen locked.
//
// In case of crash :
// - Use the safety short-cut : All the left modifiers (Ctrl, Shift, Option, Command, Alt
// or equivalents) of your keyboard and F12. That should send you back to 640x480, and
// the debugger terminal should be visible (and usable) if any.
// - Then, you can also switch to your Terminal workspace to check the last printf infos.
// - After you got (we hope) more information about your (or our :-) bug, quit the debugger
// window. Then you should be able to change your code and run your application again.
// In any case, check the Error() function immediately after the WindowScreen constructor.
// A bad error code will mean that the GameKit is in a inconsistent state, and then you
// have better to reboot your machine. If you don't want to reboot, you can also try to
// run your application in a different workspace.
//
// It's far from perfect, but we hope it will still help.
//
// The Debug API will not be support after the Preview Release (replaced by the debug
// API in the new WindowScreen class).
//**************************************************************************************
void RegisterThread( thread_id id );
virtual void SuspensionHook( bool active );
void Suspend( char* pLabel );
virtual status_t Perform( perform_code d, void* pArg );
private:
BWindowScreen();
BWindowScreen( BWindowScreen& );
BWindowScreen& operator=( BWindowScreen& );
};
#endif // GAME_KIT_WINDOW_SCREEN
+155
View File
@@ -0,0 +1,155 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Alert.h
// Author: Erik Jaesler ([email protected])
// Description: BAlert displays a modal alert window.
//------------------------------------------------------------------------------
#ifndef _ALERT_H
#define _ALERT_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <Window.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class BBitmap;
class BButton;
class BInvoker;
class BTextView;
// enum for flavors of alert ---------------------------------------------------
enum alert_type {
B_EMPTY_ALERT = 0,
B_INFO_ALERT,
B_IDEA_ALERT,
B_WARNING_ALERT,
B_STOP_ALERT
};
enum button_spacing {
B_EVEN_SPACING = 0,
B_OFFSET_SPACING
};
// BAlert class ----------------------------------------------------------------
class BAlert : public BWindow
{
public:
BAlert( const char *title,
const char *text,
const char *button1,
const char *button2 = NULL,
const char *button3 = NULL,
button_width width = B_WIDTH_AS_USUAL,
alert_type type = B_INFO_ALERT);
BAlert( const char *title,
const char *text,
const char *button1,
const char *button2,
const char *button3,
button_width width,
button_spacing spacing,
alert_type type = B_INFO_ALERT);
virtual ~BAlert();
// Archiving
BAlert(BMessage *data);
static BArchivable *Instantiate(BMessage *data);
virtual status_t Archive(BMessage *data, bool deep = true) const;
// BAlert guts
void SetShortcut(int32 button_index, char key);
char Shortcut(int32 button_index) const;
int32 Go();
status_t Go(BInvoker *invoker);
virtual void MessageReceived(BMessage *an_event);
virtual void FrameResized(float new_width, float new_height);
BButton *ButtonAt(int32 index) const;
BTextView *TextView() const;
virtual BHandler *ResolveSpecifier(BMessage *msg,
int32 index,
BMessage *specifier,
int32 form,
const char *property);
virtual status_t GetSupportedSuites(BMessage *data);
virtual void DispatchMessage(BMessage *msg, BHandler *handler);
virtual void Quit();
virtual bool QuitRequested();
static BPoint AlertPosition(float width, float height);
// Private or reserved ---------------------------------------------------------
virtual status_t Perform(perform_code d, void *arg);
private:
friend class _BAlertFilter_;
virtual void _ReservedAlert1();
virtual void _ReservedAlert2();
virtual void _ReservedAlert3();
void InitObject(const char *text,
const char *button1,
const char *button2 = NULL,
const char *button3 = NULL,
button_width width = B_WIDTH_AS_USUAL,
button_spacing spacing = B_EVEN_SPACING,
alert_type type = B_INFO_ALERT);
BBitmap *InitIcon();
sem_id fAlertSem;
int32 fAlertVal;
BButton *fButtons[3];
BTextView *fTextView;
char fKeys[3];
alert_type fMsgType;
button_width fButtonWidth;
BInvoker *fInvoker;
uint32 _reserved[4];
};
//------------------------------------------------------------------------------
#endif // _ALERT_H
/*
* $Log $
*
* $Id $
*
*/
+126
View File
@@ -0,0 +1,126 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Box.h
// Author: Marc Flerackers ([email protected])
// Description: BBox objects group views together and draw a border
// around them.
//------------------------------------------------------------------------------
#ifndef _BOX_H
#define _BOX_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <View.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
// BBox class ------------------------------------------------------------------
class BBox : public BView {
public:
BBox(BRect frame,
const char *name = NULL,
uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS |
B_NAVIGABLE_JUMP,
border_style border = B_FANCY_BORDER);
virtual ~BBox();
/* Archiving */
BBox(BMessage *archive);
static BArchivable *Instantiate(BMessage *archive);
virtual status_t Archive(BMessage *archive, bool deep = true) const;
virtual void SetBorder(border_style border);
border_style Border() const;
void SetLabel(const char *string);
status_t SetLabel(BView *viewLabel);
const char *Label() const;
BView *LabelView() const;
virtual void Draw(BRect updateRect);
virtual void AttachedToWindow();
virtual void DetachedFromWindow();
virtual void AllAttached();
virtual void AllDetached();
virtual void FrameResized(float width, float height);
virtual void MessageReceived(BMessage *message);
virtual void MouseDown(BPoint point);
virtual void MouseUp(BPoint point);
virtual void WindowActivated(bool active);
virtual void MouseMoved(BPoint point, uint32 transit,
const BMessage *message);
virtual void FrameMoved(BPoint newLocation);
virtual BHandler *ResolveSpecifier(BMessage *message,
int32 index,
BMessage *specifier,
int32 what,
const char *property);
virtual void ResizeToPreferred();
virtual void GetPreferredSize(float *width, float *height);
virtual void MakeFocus(bool focused = true);
virtual status_t GetSupportedSuites(BMessage *message);
virtual status_t Perform(perform_code d, void *arg);
private:
virtual void _ReservedBox1();
virtual void _ReservedBox2();
BBox &operator=(const BBox &);
void InitObject(BMessage *data = NULL);
void DrawPlain();
void DrawFancy();
void ClearAnyLabel();
char *fLabel;
BRect fBounds;
border_style fStyle;
BView *fLabelView;
uint32 _reserved[1];
};
//------------------------------------------------------------------------------
#endif // _BOX_H
/*
* $Log $
*
* $Id $
*
*/
+119
View File
@@ -0,0 +1,119 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Button.h
// Author: Marc Flerackers ([email protected])
// Description: BButton displays and controls a button in a window.
//------------------------------------------------------------------------------
#ifndef _BUTTON_H
#define _BUTTON_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <Control.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
// BButton class ---------------------------------------------------------------
class BButton : public BControl {
public:
BButton(BRect frame,
const char *name,
const char *label,
BMessage *message,
uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
virtual ~BButton();
BButton(BMessage *archive);
static BArchivable *Instantiate(BMessage *archive);
virtual status_t Archive (BMessage *archive, bool deep = true) const;
virtual void Draw(BRect updateRect);
virtual void MouseDown(BPoint point);
virtual void AttachedToWindow();
virtual void KeyDown(const char *bytes, int32 numBytes);
virtual void MakeDefault(bool flag);
virtual void SetLabel(const char *string);
bool IsDefault() const;
virtual void MessageReceived(BMessage *message);
virtual void WindowActivated(bool active);
virtual void MouseMoved(BPoint point, uint32 transit, const BMessage *message);
virtual void MouseUp(BPoint point);
virtual void DetachedFromWindow();
virtual void SetValue(int32 value);
virtual void GetPreferredSize (float *width, float *height);
virtual void ResizeToPreferred();
virtual status_t Invoke(BMessage *message = NULL);
virtual void FrameMoved(BPoint newLocation);
virtual void FrameResized(float width, float height);
virtual void MakeFocus(bool focused = true);
virtual void AllAttached();
virtual void AllDetached();
virtual BHandler *ResolveSpecifier(BMessage *message,
int32 index,
BMessage *specifier,
int32 what,
const char *property);
virtual status_t GetSupportedSuites(BMessage *message);
virtual status_t Perform(perform_code d, void *arg);
private:
virtual void _ReservedButton1();
virtual void _ReservedButton2();
virtual void _ReservedButton3();
BButton &operator=(const BButton &);
BRect DrawDefault(BRect bounds, bool enabled);
status_t Execute ();
float fCachedWidth;
bool fDrawAsDefault;
uint32 _reserved[3];
};
//------------------------------------------------------------------------------
#endif // _BUTTON_H
/*
* $Log $
*
* $Id $
*
*/
+111
View File
@@ -0,0 +1,111 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: CheckBox.h
// Author: Marc Flerackers ([email protected])
// Description: BCheckBox displays an on/off control.
//------------------------------------------------------------------------------
#ifndef _CHECK_BOX_H
#define _CHECK_BOX_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <Control.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
// BCheckBox class -------------------------------------------------------------
class BCheckBox : public BControl {
public:
BCheckBox(BRect frame,
const char *name,
const char *label,
BMessage *message,
uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
virtual ~BCheckBox();
/* Archiving */
BCheckBox(BMessage *archive);
static BArchivable *Instantiate(BMessage *archive);
virtual status_t Archive(BMessage *archive, bool deep = true) const;
virtual void Draw(BRect updateRect);
virtual void AttachedToWindow();
virtual void MouseDown(BPoint point);
virtual void MessageReceived(BMessage *message);
virtual void WindowActivated(bool active);
virtual void KeyDown(const char *bytes, int32 numBytes);
virtual void MouseUp(BPoint point);
virtual void MouseMoved(BPoint point, uint32 transit, const BMessage *message);
virtual void DetachedFromWindow();
virtual void SetValue(int32 value);
virtual void GetPreferredSize(float *width, float *height);
virtual void ResizeToPreferred();
virtual status_t Invoke(BMessage *message = NULL);
virtual void FrameMoved(BPoint newLocation);
virtual void FrameResized(float width, float height);
virtual BHandler *ResolveSpecifier(BMessage *message,
int32 index,
BMessage *specifier,
int32 what,
const char *property);
virtual status_t GetSupportedSuites(BMessage *message);
virtual void MakeFocus(bool focused = true);
virtual void AllAttached();
virtual void AllDetached();
virtual status_t Perform(perform_code d, void *arg);
private:
virtual void _ReservedCheckBox1();
virtual void _ReservedCheckBox2();
virtual void _ReservedCheckBox3();
BCheckBox &operator=(const BCheckBox &);
bool fOutlined;
uint32 _reserved[2];
};
//------------------------------------------------------------------------------
#endif // _CHECK_BOX_H
/*
* $Log $
*
* $Id $
*
*/
+140
View File
@@ -0,0 +1,140 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Control.h
// Author: Marc Flerackers ([email protected])
// Description: BControl is the base class for user-event handling objects.
//------------------------------------------------------------------------------
#ifndef _CONTROL_H
#define _CONTROL_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <Invoker.h>
#include <Message.h> /* For convenience */
#include <View.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
enum {
B_CONTROL_OFF = 0,
B_CONTROL_ON = 1
};
// Globals ---------------------------------------------------------------------
class BWindow;
// BControl class --------------------------------------------------------------
class BControl : public BView, public BInvoker {
public:
BControl(BRect frame,
const char *name,
const char *label,
BMessage *message,
uint32 resizingMode,
uint32 flags);
virtual ~BControl();
BControl(BMessage *archive);
static BArchivable *Instantiate(BMessage *archive);
virtual status_t Archive(BMessage *archive, bool deep = true) const;
virtual void WindowActivated(bool active);
virtual void AttachedToWindow();
virtual void MessageReceived(BMessage *message);
virtual void MakeFocus(bool focused = true);
virtual void KeyDown(const char *bytes, int32 numBytes);
virtual void MouseDown(BPoint point);
virtual void MouseUp(BPoint point);
virtual void MouseMoved(BPoint point, uint32 transit, const BMessage *message);
virtual void DetachedFromWindow();
virtual void SetLabel(const char *string);
const char *Label() const;
virtual void SetValue(int32 value);
int32 Value() const;
virtual void SetEnabled(bool enabled);
bool IsEnabled() const;
virtual void GetPreferredSize(float *width, float *height);
virtual void ResizeToPreferred();
virtual status_t Invoke(BMessage *message = NULL);
virtual BHandler *ResolveSpecifier(BMessage *message,
int32 index,
BMessage *specifier,
int32 what,
const char *property);
virtual status_t GetSupportedSuites(BMessage *message);
virtual void AllAttached();
virtual void AllDetached();
virtual status_t Perform(perform_code d, void *arg);
protected:
bool IsFocusChanging() const;
bool IsTracking() const;
void SetTracking(bool state);
void SetValueNoUpdate(int32 value);
private:
virtual void _ReservedControl1();
virtual void _ReservedControl2();
virtual void _ReservedControl3();
virtual void _ReservedControl4();
BControl &operator=(const BControl &);
void InitData(BMessage *data = NULL);
char *fLabel;
int32 fValue;
bool fEnabled;
bool fFocusChanging;
bool fTracking;
bool fWantsNav;
uint32 _reserved[4];
};
//------------------------------------------------------------------------------
#endif // _CONTROL_H
/*
* $Log $
*
* $Id $
*
*/
+311
View File
@@ -0,0 +1,311 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: GraphicsDefs.h
// Author: Frans van Nispen
// Description: BMessageFilter class creates objects that filter
// in-coming BMessages.
//------------------------------------------------------------------------------
#ifndef _GRAPHICS_DEFS_H
#define _GRAPHICS_DEFS_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <SupportDefs.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
//------------------------------------------------------------------------------
typedef struct pattern {
uint8 data[8];
} pattern;
extern _IMPEXP_BE const pattern B_SOLID_HIGH;
extern _IMPEXP_BE const pattern B_MIXED_COLORS;
extern _IMPEXP_BE const pattern B_SOLID_LOW;
//------------------------------------------------------------------------------
typedef struct rgb_color {
uint8 red;
uint8 green;
uint8 blue;
uint8 alpha;
} rgb_color;
//------------------------------------------------------------------------------
extern _IMPEXP_BE const rgb_color B_TRANSPARENT_COLOR;
extern _IMPEXP_BE const uint8 B_TRANSPARENT_MAGIC_CMAP8;
extern _IMPEXP_BE const uint16 B_TRANSPARENT_MAGIC_RGBA15;
extern _IMPEXP_BE const uint16 B_TRANSPARENT_MAGIC_RGBA15_BIG;
extern _IMPEXP_BE const uint32 B_TRANSPARENT_MAGIC_RGBA32;
extern _IMPEXP_BE const uint32 B_TRANSPARENT_MAGIC_RGBA32_BIG;
extern _IMPEXP_BE const uint8 B_TRANSPARENT_8_BIT;
extern _IMPEXP_BE const rgb_color B_TRANSPARENT_32_BIT;
//------------------------------------------------------------------------------
typedef struct color_map {
int32 id;
rgb_color color_list[256];
uint8 inversion_map[256];
uint8 index_map[32768];
} color_map;
typedef struct overlay_rect_limits {
uint16 horizontal_alignment;
uint16 vertical_alignment;
uint16 width_alignment;
uint16 height_alignment;
uint16 min_width;
uint16 max_width;
uint16 min_height;
uint16 max_height;
uint32 reserved[8];
} overlay_rect_limits;
typedef struct overlay_restrictions {
overlay_rect_limits source;
overlay_rect_limits destination;
float min_width_scale;
float max_width_scale;
float min_height_scale;
float max_height_scale;
uint32 reserved[8];
} overlay_restrictions;
//------------------------------------------------------------------------------
struct screen_id { int32 id; };
extern _IMPEXP_BE const struct screen_id B_MAIN_SCREEN_ID;
//------------------------------------------------------------------------------
typedef enum
{
B_NO_COLOR_SPACE = 0x0000, //* byte in memory order, high bit first
// linear color space (little endian is the default)
B_RGB32 = 0x0008, //* B[7:0] G[7:0] R[7:0] -[7:0]
B_RGBA32 = 0x2008, // B[7:0] G[7:0] R[7:0] A[7:0]
B_RGB24 = 0x0003, // B[7:0] G[7:0] R[7:0]
B_RGB16 = 0x0005, // G[2:0],B[4:0] R[4:0],G[5:3]
B_RGB15 = 0x0010, // G[2:0],B[4:0] -[0],R[4:0],G[4:3]
B_RGBA15 = 0x2010, // G[2:0],B[4:0] A[0],R[4:0],G[4:3]
B_CMAP8 = 0x0004, // D[7:0]
B_GRAY8 = 0x0002, // Y[7:0]
B_GRAY1 = 0x0001, // Y0[0],Y1[0],Y2[0],Y3[0],Y4[0],Y5[0],Y6[0],Y7[0]
// big endian version, when the encoding is not endianess independant
B_RGB32_BIG = 0x1008, // -[7:0] R[7:0] G[7:0] B[7:0]
B_RGBA32_BIG = 0x3008, // A[7:0] R[7:0] G[7:0] B[7:0]
B_RGB24_BIG = 0x1003, // R[7:0] G[7:0] B[7:0]
B_RGB16_BIG = 0x1005, // R[4:0],G[5:3] G[2:0],B[4:0]
B_RGB15_BIG = 0x1010, // -[0],R[4:0],G[4:3] G[2:0],B[4:0]
B_RGBA15_BIG = 0x3010, // A[0],R[4:0],G[4:3] G[2:0],B[4:0]
// little-endian declarations, for completness
B_RGB32_LITTLE = B_RGB32,
B_RGBA32_LITTLE = B_RGBA32,
B_RGB24_LITTLE = B_RGB24,
B_RGB16_LITTLE = B_RGB16,
B_RGB15_LITTLE = B_RGB15,
B_RGBA15_LITTLE = B_RGBA15,
// non linear color space -- note that these are here for exchange purposes;
// a BBitmap or BView may not necessarily support all these color spaces.
// Loss/Saturation points are Y 16-235 (absoulte); Cb/Cr 16-240 (center 128)
B_YCbCr422 = 0x4000, // Y0[7:0] Cb0[7:0] Y1[7:0] Cr0[7:0] Y2[7:0]...
// Cb2[7:0] Y3[7:0] Cr2[7:0]
B_YCbCr411 = 0x4001, // Cb0[7:0] Y0[7:0] Cr0[7:0] Y1[7:0] Cb4[7:0]...
// Y2[7:0] Cr4[7:0] Y3[7:0] Y4[7:0] Y5[7:0]...
// Y6[7:0] Y7[7:0]
B_YCbCr444 = 0x4003, // Y0[7:0] Cb0[7:0] Cr0[7:0]
B_YCbCr420 = 0x4004, // Non-interlaced only, Cb0 Y0 Y1 Cb2 Y2 Y3
// on even scan lines, Cr0 Y0 Y1 Cr2 Y2 Y3
// on odd scan lines
// Extrema points are
// Y 0 - 207 (absolute)
// U -91 - 91 (offset 128)
// V -127 - 127 (offset 128)
// note that YUV byte order is different from YCbCr
// USE YCbCr, not YUV, when that's what you mean!
B_YUV422 = 0x4020, // U0[7:0] Y0[7:0] V0[7:0] Y1[7:0] ...
// U2[7:0] Y2[7:0] V2[7:0] Y3[7:0]
B_YUV411 = 0x4021, // U0[7:0] Y0[7:0] Y1[7:0] V0[7:0] Y2[7:0] Y3[7:0]
// U4[7:0] Y4[7:0] Y5[7:0] V4[7:0] Y6[7:0] Y7[7:0]
B_YUV444 = 0x4023, // U0[7:0] Y0[7:0] V0[7:0] U1[7:0] Y1[7:0] V1[7:0]
B_YUV420 = 0x4024, // Non-interlaced only, U0 Y0 Y1 U2 Y2 Y3
// on even scan lines, V0 Y0 Y1 V2 Y2 Y3
// on odd scan lines
B_YUV9 = 0x402C, // planar? 410?
B_YUV12 = 0x402D, // planar? 420?
B_UVL24 = 0x4030, // U0[7:0] V0[7:0] L0[7:0] ...
B_UVL32 = 0x4031, // U0[7:0] V0[7:0] L0[7:0] X0[7:0]...
B_UVLA32 = 0x6031, // U0[7:0] V0[7:0] L0[7:0] A0[7:0]...
B_LAB24 = 0x4032, // L0[7:0] a0[7:0] b0[7:0] ... (a is not alpha!)
B_LAB32 = 0x4033, // L0[7:0] a0[7:0] b0[7:0] X0[7:0] ... (b is not alpha!)
B_LABA32 = 0x6033, // L0[7:0] a0[7:0] b0[7:0] A0[7:0] ... (A is alpha)
// red is at hue = 0
B_HSI24 = 0x4040, // H[7:0] S[7:0] I[7:0]
B_HSI32 = 0x4041, // H[7:0] S[7:0] I[7:0] X[7:0]
B_HSIA32 = 0x6041, // H[7:0] S[7:0] I[7:0] A[7:0]
B_HSV24 = 0x4042, // H[7:0] S[7:0] V[7:0]
B_HSV32 = 0x4043, // H[7:0] S[7:0] V[7:0] X[7:0]
B_HSVA32 = 0x6043, // H[7:0] S[7:0] V[7:0] A[7:0]
B_HLS24 = 0x4044, // H[7:0] L[7:0] S[7:0]
B_HLS32 = 0x4045, // H[7:0] L[7:0] S[7:0] X[7:0]
B_HLSA32 = 0x6045, // H[7:0] L[7:0] S[7:0] A[7:0]
B_CMY24 = 0xC001, // C[7:0] M[7:0] Y[7:0] No gray removal done
B_CMY32 = 0xC002, // C[7:0] M[7:0] Y[7:0] X[7:0] No gray removal done
B_CMYA32 = 0xE002, // C[7:0] M[7:0] Y[7:0] A[7:0] No gray removal done
B_CMYK32 = 0xC003, // C[7:0] M[7:0] Y[7:0] K[7:0]
// compatibility declarations
B_MONOCHROME_1_BIT = B_GRAY1,
B_GRAYSCALE_8_BIT = B_GRAY8,
B_COLOR_8_BIT = B_CMAP8,
B_RGB_32_BIT = B_RGB32,
B_RGB_16_BIT = B_RGB15,
B_BIG_RGB_32_BIT = B_RGB32_BIG,
B_BIG_RGB_16_BIT = B_RGB15_BIG
} color_space;
// Find out whether a specific color space is supported by BBitmaps.
// Support_flags will be set to what kinds of support are available.
// If support_flags is set to 0, false will be returned.
enum {
B_VIEWS_SUPPORT_DRAW_BITMAP = 0x1,
B_BITMAPS_SUPPORT_ATTACHED_VIEWS = 0x2
};
_IMPEXP_BE bool bitmaps_support_space(color_space space, uint32 * support_flags);
//------------------------------------------------------------------------------
// "pixel_chunk" is the native increment from one pixel starting on an integral byte
// to the next. "row_alignment" is the native alignment for pixel scanline starts.
// "pixels_per_chunk" is the number of pixels in a pixel_chunk. For instance, B_GRAY1
// sets pixel_chunk to 1, row_alignment to 4 and pixels_per_chunk to 8, whereas
// B_RGB24 sets pixel_chunk to 3, row_alignment to 4 and pixels_per_chunk to 1.
//------------------------------------------------------------------------------
_IMPEXP_BE status_t get_pixel_size_for(color_space space, size_t * pixel_chunk,
size_t * row_alignment, size_t * pixels_per_chunk);
enum buffer_orientation {
B_BUFFER_TOP_TO_BOTTOM,
B_BUFFER_BOTTOM_TO_TOP
};
enum buffer_layout {
B_BUFFER_NONINTERLEAVED = 1
};
//------------------------------------------------------------------------------
enum drawing_mode {
B_OP_COPY,
B_OP_OVER,
B_OP_ERASE,
B_OP_INVERT,
B_OP_ADD,
B_OP_SUBTRACT,
B_OP_BLEND,
B_OP_MIN,
B_OP_MAX,
B_OP_SELECT,
B_OP_ALPHA
};
enum source_alpha {
B_PIXEL_ALPHA=0,
B_CONSTANT_ALPHA
};
enum alpha_function {
B_ALPHA_OVERLAY=0,
B_ALPHA_COMPOSITE
};
enum {
B_8_BIT_640x480 = 0x00000001,
B_8_BIT_800x600 = 0x00000002,
B_8_BIT_1024x768 = 0x00000004,
B_8_BIT_1280x1024 = 0x00000008,
B_8_BIT_1600x1200 = 0x00000010,
B_16_BIT_640x480 = 0x00000020,
B_16_BIT_800x600 = 0x00000040,
B_16_BIT_1024x768 = 0x00000080,
B_16_BIT_1280x1024 = 0x00000100,
B_16_BIT_1600x1200 = 0x00000200,
B_32_BIT_640x480 = 0x00000400,
B_32_BIT_800x600 = 0x00000800,
B_32_BIT_1024x768 = 0x00001000,
B_32_BIT_1280x1024 = 0x00002000,
B_32_BIT_1600x1200 = 0x00004000,
B_8_BIT_1152x900 = 0x00008000,
B_16_BIT_1152x900 = 0x00010000,
B_32_BIT_1152x900 = 0x00020000,
B_15_BIT_640x480 = 0x00040000,
B_15_BIT_800x600 = 0x00080000,
B_15_BIT_1024x768 = 0x00100000,
B_15_BIT_1280x1024 = 0x00200000,
B_15_BIT_1600x1200 = 0x00400000,
B_15_BIT_1152x900 = 0x00800000,
// do not use B_FAKE_DEVICE--it will go away!
B_FAKE_DEVICE = 0x40000000,
B_8_BIT_640x400 = (int)0x80000000
};
#endif // _GRAPHICSDEFS_H
/*
* $Log $
*
* $Id $
*
*/
+88
View File
@@ -0,0 +1,88 @@
/******************************************************************************
/
/ File: Input.h
/
/ Description: Functions and class to manage input devices.
/
/ Copyright 1998, Be Incorporated, All Rights Reserved.
/
******************************************************************************/
#ifndef _INPUT_H
#define _INPUT_H
#include <BeBuild.h>
#include <Messenger.h>
#include <SupportDefs.h>
enum input_method_op {
B_INPUT_METHOD_STARTED = 0,
B_INPUT_METHOD_STOPPED = 1,
B_INPUT_METHOD_CHANGED = 2,
B_INPUT_METHOD_LOCATION_REQUEST = 3
};
enum input_device_type {
B_POINTING_DEVICE = 0,
B_KEYBOARD_DEVICE = 1,
B_UNDEFINED_DEVICE = 2
};
/*
what == B_INPUT_DEVICES_CHANGED
FindString("name", name_of_device);
FindInt32("opcode", input_device_notification);
*/
enum input_device_notification {
B_INPUT_DEVICE_ADDED = 0x0001,
B_INPUT_DEVICE_STARTED = 0x0002,
B_INPUT_DEVICE_STOPPED = 0x0004,
B_INPUT_DEVICE_REMOVED = 0x0008
};
class BInputDevice;
_IMPEXP_BE BInputDevice* find_input_device(const char *name);
_IMPEXP_BE status_t get_input_devices(BList *list);
_IMPEXP_BE status_t watch_input_devices(BMessenger target, bool start);
class BInputDevice {
public:
~BInputDevice();
const char* Name() const;
input_device_type Type() const;
bool IsRunning() const;
status_t Start();
status_t Stop();
status_t Control(uint32 code,
BMessage *message);
static status_t Start(input_device_type type);
static status_t Stop(input_device_type type);
static status_t Control(input_device_type type,
uint32 code,
BMessage *message);
private:
friend BInputDevice* find_input_device(const char *name);
friend status_t get_input_devices(BList *list);
BInputDevice();
void set_name_and_type(const char *name,
input_device_type type);
char* fName;
input_device_type fType;
uint32 _reserved[4];
};
#endif
+366
View File
@@ -0,0 +1,366 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: InterfaceDefs.h
// Author: Erik Jaesler ([email protected])
// Description: General Interface Kit definitions and global functions.
//------------------------------------------------------------------------------
#ifndef _INTERFACE_DEFS_H
#define _INTERFACE_DEFS_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <GraphicsDefs.h>
#include <OS.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class BRect;
/*----------------------------------------------------------------*/
struct key_info {
uint32 modifiers;
uint8 key_states[16];
};
/*----------------------------------------------------------------*/
#define B_UTF8_ELLIPSIS "\xE2\x80\xA6"
#define B_UTF8_OPEN_QUOTE "\xE2\x80\x9C"
#define B_UTF8_CLOSE_QUOTE "\xE2\x80\x9D"
#define B_UTF8_COPYRIGHT "\xC2\xA9"
#define B_UTF8_REGISTERED "\xC2\xAE"
#define B_UTF8_TRADEMARK "\xE2\x84\xA2"
#define B_UTF8_SMILING_FACE "\xE2\x98\xBB"
#define B_UTF8_HIROSHI "\xE5\xBC\x98"
/*----------------------------------------------------------------*/
enum { B_BACKSPACE = 0x08,
B_RETURN = 0x0a,
B_ENTER = 0x0a,
B_SPACE = 0x20,
B_TAB = 0x09,
B_ESCAPE = 0x1b,
B_SUBSTITUTE = 0x1a,
B_LEFT_ARROW = 0x1c,
B_RIGHT_ARROW = 0x1d,
B_UP_ARROW = 0x1e,
B_DOWN_ARROW = 0x1f,
B_INSERT = 0x05,
B_DELETE = 0x7f,
B_HOME = 0x01,
B_END = 0x04,
B_PAGE_UP = 0x0b,
B_PAGE_DOWN = 0x0c,
B_FUNCTION_KEY = 0x10 };
enum { B_F1_KEY = 0x02,
B_F2_KEY = 0x03,
B_F3_KEY = 0x04,
B_F4_KEY = 0x05,
B_F5_KEY = 0x06,
B_F6_KEY = 0x07,
B_F7_KEY = 0x08,
B_F8_KEY = 0x09,
B_F9_KEY = 0x0a,
B_F10_KEY = 0x0b,
B_F11_KEY = 0x0c,
B_F12_KEY = 0x0d,
B_PRINT_KEY = 0x0e,
B_SCROLL_KEY = 0x0f,
B_PAUSE_KEY = 0x10 };
struct key_map {
uint32 version;
uint32 caps_key;
uint32 scroll_key;
uint32 num_key;
uint32 left_shift_key;
uint32 right_shift_key;
uint32 left_command_key;
uint32 right_command_key;
uint32 left_control_key;
uint32 right_control_key;
uint32 left_option_key;
uint32 right_option_key;
uint32 menu_key;
uint32 lock_settings;
int32 control_map[128];
int32 option_caps_shift_map[128];
int32 option_caps_map[128];
int32 option_shift_map[128];
int32 option_map[128];
int32 caps_shift_map[128];
int32 caps_map[128];
int32 shift_map[128];
int32 normal_map[128];
int32 acute_dead_key[32];
int32 grave_dead_key[32];
int32 circumflex_dead_key[32];
int32 dieresis_dead_key[32];
int32 tilde_dead_key[32];
uint32 acute_tables;
uint32 grave_tables;
uint32 circumflex_tables;
uint32 dieresis_tables;
uint32 tilde_tables;
};
struct mouse_map {
uint32 left;
uint32 right;
uint32 middle;
};
/*----------------------------------------------------------------*/
enum border_style {
B_PLAIN_BORDER,
B_FANCY_BORDER,
B_NO_BORDER
};
/*----------------------------------------------------------------*/
enum orientation {
B_HORIZONTAL,
B_VERTICAL
};
/*----------------------------------------------------------------*/
enum button_width {
B_WIDTH_AS_USUAL,
B_WIDTH_FROM_WIDEST,
B_WIDTH_FROM_LABEL
};
/*----------------------------------------------------------------*/
enum join_mode {
B_ROUND_JOIN=0,
B_MITER_JOIN,
B_BEVEL_JOIN,
B_BUTT_JOIN,
B_SQUARE_JOIN
};
enum cap_mode {
B_ROUND_CAP=B_ROUND_JOIN,
B_BUTT_CAP=B_BUTT_JOIN,
B_SQUARE_CAP=B_SQUARE_JOIN
};
const float B_DEFAULT_MITER_LIMIT = 10.0F;
/*----------------------------------------------------------------*/
struct scroll_bar_info {
bool proportional;
bool double_arrows;
int32 knob;
int32 min_knob_size;
};
/*----------------------------------------------------------------*/
enum alignment {
B_ALIGN_LEFT,
B_ALIGN_RIGHT,
B_ALIGN_CENTER
};
enum vertical_alignment {
B_ALIGN_TOP = 0x10L,
B_ALIGN_MIDDLE = 0x20,
B_ALIGN_BOTTOM = 0x30,
B_ALIGN_NO_VERTICAL = -1L
};
/*----------------------------------------------------------------*/
enum {
B_CONTROL_TABLE = 0x00000001,
B_OPTION_CAPS_SHIFT_TABLE = 0x00000002,
B_OPTION_CAPS_TABLE = 0x00000004,
B_OPTION_SHIFT_TABLE = 0x00000008,
B_OPTION_TABLE = 0x00000010,
B_CAPS_SHIFT_TABLE = 0x00000020,
B_CAPS_TABLE = 0x00000040,
B_SHIFT_TABLE = 0x00000080,
B_NORMAL_TABLE = 0x00000100
};
/*----------------------------------------------------------------*/
enum {
B_SHIFT_KEY = 0x00000001,
B_COMMAND_KEY = 0x00000002,
B_CONTROL_KEY = 0x00000004,
B_CAPS_LOCK = 0x00000008,
B_SCROLL_LOCK = 0x00000010,
B_NUM_LOCK = 0x00000020,
B_OPTION_KEY = 0x00000040,
B_MENU_KEY = 0x00000080,
B_LEFT_SHIFT_KEY = 0x00000100,
B_RIGHT_SHIFT_KEY = 0x00000200,
B_LEFT_COMMAND_KEY = 0x00000400,
B_RIGHT_COMMAND_KEY = 0x00000800,
B_LEFT_CONTROL_KEY = 0x00001000,
B_RIGHT_CONTROL_KEY = 0x00002000,
B_LEFT_OPTION_KEY = 0x00004000,
B_RIGHT_OPTION_KEY = 0x00008000
};
/*----------------------------------------------------------------*/
enum bitmap_tiling {
B_TILE_BITMAP_X = 0x00000001,
B_TILE_BITMAP_Y = 0x00000002,
B_TILE_BITMAP = 0x00000003
};
enum overlay_options {
B_OVERLAY_FILTER_HORIZONTAL = 0x00010000,
B_OVERLAY_FILTER_VERTICAL = 0x00020000,
B_OVERLAY_MIRROR = 0x00040000,
B_OVERLAY_TRANSFER_CHANNEL = 0x00080000
};
/*----------------------------------------------------------------*/
_IMPEXP_BE status_t get_deskbar_frame(BRect *frame);
_IMPEXP_BE const color_map *system_colors();
_IMPEXP_BE status_t set_screen_space(int32 index, uint32 res,
bool stick = true);
_IMPEXP_BE status_t get_scroll_bar_info(scroll_bar_info *info);
_IMPEXP_BE status_t set_scroll_bar_info(scroll_bar_info *info);
_IMPEXP_BE status_t get_mouse_type(int32 *type);
_IMPEXP_BE status_t set_mouse_type(int32 type);
_IMPEXP_BE status_t get_mouse_map(mouse_map *map);
_IMPEXP_BE status_t set_mouse_map(mouse_map *map);
_IMPEXP_BE status_t get_click_speed(bigtime_t *speed);
_IMPEXP_BE status_t set_click_speed(bigtime_t speed);
_IMPEXP_BE status_t get_mouse_speed(int32 *speed);
_IMPEXP_BE status_t set_mouse_speed(int32 speed);
_IMPEXP_BE status_t get_mouse_acceleration(int32 *speed);
_IMPEXP_BE status_t set_mouse_acceleration(int32 speed);
_IMPEXP_BE status_t get_key_repeat_rate(int32 *rate);
_IMPEXP_BE status_t set_key_repeat_rate(int32 rate);
_IMPEXP_BE status_t get_key_repeat_delay(bigtime_t *delay);
_IMPEXP_BE status_t set_key_repeat_delay(bigtime_t delay);
_IMPEXP_BE uint32 modifiers();
_IMPEXP_BE status_t get_key_info(key_info *info);
_IMPEXP_BE void get_key_map(key_map **map, char **key_buffer);
_IMPEXP_BE status_t get_keyboard_id(uint16 *id);
_IMPEXP_BE void set_modifier_key(uint32 modifier, uint32 key);
_IMPEXP_BE void set_keyboard_locks(uint32 modifiers);
_IMPEXP_BE rgb_color keyboard_navigation_color();
_IMPEXP_BE int32 count_workspaces();
_IMPEXP_BE void set_workspace_count(int32 count);
_IMPEXP_BE int32 current_workspace();
_IMPEXP_BE void activate_workspace(int32 workspace);
_IMPEXP_BE bigtime_t idle_time();
_IMPEXP_BE void run_select_printer_panel();
_IMPEXP_BE void run_add_printer_panel();
_IMPEXP_BE void run_be_about();
_IMPEXP_BE void set_focus_follows_mouse(bool follow);
_IMPEXP_BE bool focus_follows_mouse();
enum mode_mouse {
B_NORMAL_MOUSE = 0,
B_FOCUS_FOLLOWS_MOUSE = 1,
B_WARP_MOUSE = 3,
B_INSTANT_WARP_MOUSE = 7
};
_IMPEXP_BE void set_mouse_mode(mode_mouse mode);
_IMPEXP_BE mode_mouse mouse_mode();
enum color_which {
B_PANEL_BACKGROUND_COLOR = 1,
B_MENU_BACKGROUND_COLOR = 2,
B_MENU_SELECTION_BACKGROUND_COLOR = 6,
B_MENU_ITEM_TEXT_COLOR = 7,
B_MENU_SELECTED_ITEM_TEXT_COLOR = 8,
B_WINDOW_TAB_COLOR = 3,
B_KEYBOARD_NAVIGATION_COLOR = 4,
B_DESKTOP_COLOR = 5
};
_IMPEXP_BE rgb_color ui_color(color_which which);
_IMPEXP_BE rgb_color tint_color(rgb_color color, float tint);
extern "C" status_t _init_interface_kit_();
/* effects on standard gray level */
const float B_LIGHTEN_MAX_TINT = 0.0F; /* 216 --> 255.0 (255) */
const float B_LIGHTEN_2_TINT = 0.385F; /* 216 --> 240.0 (240) */
const float B_LIGHTEN_1_TINT = 0.590F; /* 216 --> 232.0 (232) */
const float B_NO_TINT = 1.0F; /* 216 --> 216.0 (216) */
const float B_DARKEN_1_TINT = 1.147F; /* 216 --> 184.2 (184) */
const float B_DARKEN_2_TINT = 1.295F; /* 216 --> 152.3 (152) */
const float B_DARKEN_3_TINT = 1.407F; /* 216 --> 128.1 (128) */
const float B_DARKEN_4_TINT = 1.555F; /* 216 --> 96.1 (96) */
const float B_DARKEN_MAX_TINT = 2.0F; /* 216 --> 0.0 (0) */
const float B_DISABLED_LABEL_TINT = B_DARKEN_3_TINT;
const float B_HIGHLIGHT_BACKGROUND_TINT = B_DARKEN_2_TINT;
const float B_DISABLED_MARK_TINT = B_LIGHTEN_2_TINT;
/*-------------------------------------------------------------*/
/*-------------------------------------------------------------*/
#endif // _INTERFACE_DEFS_H
/*
* $Log $
*
* $Id $
*
*/
+103
View File
@@ -0,0 +1,103 @@
////////////////////////////////////////////////////////////////////////////////
//
// File: ListItem.h
//
// Description: BListView represents a one-dimensional list view.
//
// Copyright 2001, Ulrich Wimboeck
//
////////////////////////////////////////////////////////////////////////////////
#ifndef _LIST_ITEM_H
#define _LIST_ITEM_H
#include <BeBuild.h>
#include <Archivable.h>
#include <Rect.h>
class BFont ;
class BMessage ;
class BOutlineListView ;
class BView ;
#ifdef USE_OPENBEOS_NAMESPACE
namespace OpenBeOS
{
#endif
/*----------------------------------------------------------------*/
/*----- BListItem class ------------------------------------------*/
/**
* A BListItem represents a single item in a BListView (or
* BOutlineListView). The BListItem object provides drawing
* instructions that can draw the item (through DrawItem()), and
* keeps track of the item's state. To use a BListItem, you must
* add it to a BListView through BListView::AddItem()
* (BOutlineListView provides additional item-adding functions).
* The BListView object provides the drawing context for the
* BListItem's DrawItem() function.
*
* BListItem is abstract; each subclass must implement DrawItem().
* BStringItem—the only BListItem subclass provided by
* Be—implements the function to draw the item as a line of text.
*/
class BListItem : public BArchivable
{
public:
BListItem(uint32 outlineLevel = 0, bool expanded = true) ;
BListItem(BMessage* data) ;
virtual ~BListItem() ;
virtual status_t Archive(BMessage* data, bool deep = true) const ;
float Height() const ;
float Width() const ;
bool IsSelected() const ;
void Select() ;
void Deselect() ;
virtual void SetEnabled(bool on) ;
bool IsEnabled() const ;
void SetHeight(float height) ;
void SetWidth(float width) ;
virtual void DrawItem(BView* owner, BRect bounds, bool complete = false) = 0 ;
virtual void Update(BView* owner, const BFont* font) ;
virtual status_t Perform(perform_code d, void* arg) ;
bool IsExpanded() const ;
void SetExpanded(bool expanded) ;
uint32 OutlineLevel() const ;
/*----- Private or reserved -----------------------------------------*/
private:
friend class BOutlineListView ;
BListItem(const BListItem&) ;
BListItem& operator=(const BListItem&) ;
float fWidth ;
float fHeight ;
uint32 fLevel ;
bool fSelected ;
bool fEnabled ;
bool fExpanded ;
bool fHasSubItems ;
bool fVisible ;
} ;
// in the interface kit the BStringItem class is declared within ListItem.h
#ifndef USE_OPENBEOS_NAMESPACE
#include "StringItem.h"
#endif
#ifdef USE_OPENBEOS_NAMESPACE
}
#endif
#endif /* _LIST_ITEM_H */
+213
View File
@@ -0,0 +1,213 @@
////////////////////////////////////////////////////////////////////////////////
//
// File: ListView.h
//
// Description: BListView represents a one-dimensional list view.
//
// Copyright 2001, Ulrich Wimboeck
//
////////////////////////////////////////////////////////////////////////////////
#ifndef _LIST_VIEW_H
#define _LIST_VIEW_H
#include <BeBuild.h>
#include <List.h>
#include <ListItem.h>
#include <Invoker.h>
#include <View.h>
struct track_data ;
enum list_view_type {
B_SINGLE_SELECTION_LIST,
B_MULTIPLE_SELECTION_LIST
};
#ifdef USE_OPENBEOS_NAMESPACE
namespace OpenBeOS
{
#endif
/*----------------------------------------------------------------*/
/*----- BListView class ------------------------------------------*/
/**
* A BListView displays a list of items the user can select and
* invoke. Each item is a kind of BListItem object. The BListView
* manages the layout of the list and the interaction with the user;
* it leaves the display of each item to the BListItem objects.
* A BListItem is not a view and draws only when called upon by
* the BListView.
*/
class BListView : public BView, public BInvoker
{
public:
BListView(BRect frame, const char* name,
list_view_type type = B_SINGLE_SELECTION_LIST,
uint32 resizeMask = B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE) ;
BListView(BMessage* data) ;
virtual ~BListView() ;
static BArchivable* Instantiate(BMessage* data) ;
virtual status_t Archive(BMessage* data, bool deep = true) const ;
virtual void Draw(BRect updateRect) ;
virtual void MessageReceived(BMessage* msg) ;
virtual void MouseDown(BPoint where) ;
virtual void KeyDown(const char* bytes, int32 numBytes) ;
virtual void MakeFocus(bool state = true) ;
virtual void FrameResized(float newWidth, float newHeight) ;
virtual void TargetedByScrollView(BScrollView* scroller) ;
void ScrollTo(float x, float y) ;
virtual void ScrollTo(BPoint where) ;
virtual bool AddItem(BListItem* item) ;
virtual bool AddItem(BListItem* item, int32 atIndex) ;
virtual bool AddList(BList* newItems) ;
virtual bool AddList(BList* newItems, int32 atIndex) ;
virtual bool RemoveItem(BListItem* item) ;
virtual BListItem* RemoveItem(int32 index) ;
virtual bool RemoveItems(int32 index, int32 count) ;
virtual void SetSelectionMessage(BMessage* message) ;
virtual void SetInvocationMessage(BMessage* message) ;
BMessage* SelectionMessage() const ;
uint32 SelectionCommand() const ;
BMessage* InvocationMessage() const ;
uint32 InvocationCommand() const ;
virtual void SetListType(list_view_type type) ;
list_view_type ListType() const ;
BListItem* ItemAt(int32 index) const ;
int32 IndexOf(BPoint point) const ;
int32 IndexOf(BListItem *item) const ;
BListItem* FirstItem() const ;
BListItem* LastItem() const ;
bool HasItem(BListItem *item) const ;
int32 CountItems() const ;
virtual void MakeEmpty() ;
bool IsEmpty() const ;
void DoForEach(bool (*func)(BListItem *)) ;
void DoForEach(bool (*func)(BListItem *, void *), void *) ;
const BListItem **Items() const ;
void InvalidateItem(int32 index) ;
void ScrollToSelection() ;
void Select(int32 index, bool extend = false) ;
void Select(int32 from, int32 to, bool extend = false) ;
bool IsItemSelected(int32 index) const ;
int32 CurrentSelection(int32 index = 0) const ;
virtual status_t Invoke(BMessage* msg = NULL) ;
void DeselectAll() ;
void DeselectExcept(int32 except_from, int32 except_to) ;
void Deselect(int32 index) ;
virtual void SelectionChanged() ;
void SortItems(int (*cmp)(const void *, const void *)) ;
/* These functions bottleneck through DoMiscellaneous() */
bool SwapItems(int32 a, int32 b) ;
bool MoveItem(int32 from, int32 to) ;
bool ReplaceItem(int32 index, BListItem* item) ;
virtual void AttachedToWindow() ;
virtual void FrameMoved(BPoint new_position) ;
BRect ItemFrame(int32 index) ;
virtual BHandler* ResolveSpecifier(BMessage* msg,
int32 index,
BMessage* specifier,
int32 form,
const char* property) ;
virtual status_t GetSupportedSuites(BMessage* data) ;
virtual status_t Perform(perform_code d, void* arg) ;
virtual void WindowActivated(bool state) ;
virtual void MouseUp(BPoint pt) ;
virtual void MouseMoved(BPoint pt, uint32 code, const BMessage* msg) ;
virtual void DetachedFromWindow() ;
virtual bool InitiateDrag(BPoint pt, int32 itemIndex,
bool initialySelected) ;
virtual void ResizeToPreferred() ;
virtual void GetPreferredSize(float* width, float* height) ;
virtual void AllAttached() ;
virtual void AllDetached() ;
protected:
enum MiscCode { B_NO_OP, B_REPLACE_OP, B_MOVE_OP, B_SWAP_OP } ;
union MiscData {
struct Spare { int32 data[5] ; } ;
struct Replace { int32 index ; BListItem* item ; } replace ;
struct Move { int32 from; int32 to; } move ;
struct Swap { int32 a ; int32 b ; } swap ;
} ;
virtual bool DoMiscellaneous(MiscCode code, MiscData* data) ;
/*----- Private or reserved -----------------------------------------*/
private:
friend class BOutlineListView ; // try to remove friend classes
BListView& operator=(const BListView&) ;
void InitObject(list_view_type type) ;
void FixupScrollBar() ;
void InvalidateFrom(int32 index) ;
status_t PostMsg(BMessage* msg) ;
void FontChanged() ;
int32 RangeCheck(int32 index) ;
bool _Select(int32 index, bool extend) ;
bool _Select(int32 from, int32 to, bool extend) ;
bool _Deselect(int32 index) ;
void Deselect(int32 from, int32 to) ;
bool _DeselectAll(int32 except_from, int32 except_to) ;
void PerformDelayedSelect() ;
bool TryInitiateDrag(BPoint where) ;
int32 CalcFirstSelected(int32 after) ;
int32 CalcLastSelected(int32 before) ;
virtual void DrawItem(BListItem* item, BRect itemRect,
bool complete = false) ;
bool DoSwapItems(int32 a, int32 b) ;
bool DoMoveItem(int32 from, int32 to) ;
bool DoReplaceItem(int32 index, BListItem* item) ;
void RescanSelection(int32 from, int32 to) ;
void DoMouseUp(BPoint where) ;
void DoMouseMoved(BPoint where) ;
BList fList ;
list_view_type fListType ;
int32 fFirstSelected ;
int32 fLastSelected ;
int32 fAnchorIndex ;
float fWidth ;
BMessage* fSelectMessage ;
BScrollView* fScrollView ;
track_data* fTrack ;
} ;
inline void BListView::ScrollTo(float x, float y)
/* OK, no private parts */
{ ScrollTo(BPoint(x, y)) ; }
/*-------------------------------------------------------------*/
/*-------------------------------------------------------------*/
#ifdef USE_OPENBEOS_NAMESPACE
}
#endif
#endif /* _LIST_VIEW_H */
+114
View File
@@ -0,0 +1,114 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Point.h
// Author: Frans van Nispen
// Description: BPoint represents a single x,y coordinate.
//------------------------------------------------------------------------------
#ifndef _POINT_H
#define _POINT_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <SupportDefs.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class BRect;
// BPoint class ----------------------------------------------------------------
class BPoint {
public:
float x;
float y;
BPoint();
BPoint(float X, float Y);
BPoint(const BPoint &p);
BPoint &operator=(const BPoint &p);
void Set(float X, float Y);
void ConstrainTo(BRect r);
void PrintToStream() const;
BPoint operator+(const BPoint &p) const;
BPoint operator-(const BPoint &p) const;
BPoint& operator+=(const BPoint &p);
BPoint& operator-=(const BPoint &p);
bool operator!=(const BPoint &p) const;
bool operator==(const BPoint &p) const;
};
//------------------------------------------------------------------------------
extern _IMPEXP_BE const BPoint B_ORIGIN; // returns (0,0)
//------------------------------------------------------------------------------
inline BPoint::BPoint()
{
x = y = 0;
}
//------------------------------------------------------------------------------
inline BPoint::BPoint(float X, float Y)
{
x = X;
y = Y;
}
//------------------------------------------------------------------------------
inline BPoint::BPoint(const BPoint& pt)
{
x = pt.x;
y = pt.y;
}
//------------------------------------------------------------------------------
inline BPoint &BPoint::operator=(const BPoint& from)
{
x = from.x;
y = from.y;
return *this;
}
//------------------------------------------------------------------------------
inline void BPoint::Set(float X, float Y)
{
x = X;
y = Y;
}
//------------------------------------------------------------------------------
#endif // _POINT_H
/*
* $Log $
*
* $Id $
*
*/
+123
View File
@@ -0,0 +1,123 @@
/*******************************************************************************
/
/ File: PrintJob.h
/
/ Description: BPrintJob runs a printing session.
/
/ Copyright 1996-98, Be Incorporated, All Rights Reserved
/
*******************************************************************************/
#ifndef _PRINTSESSION_H
#define _PRINTSESSION_H
#include <BeBuild.h>
#include <Picture.h> /* For convenience */
#include <Rect.h>
class BView;
/*----------------------------------------------------------------*/
/*----- BPrintJob related structures -----------------------------*/
struct print_file_header {
int32 version;
int32 page_count;
off_t first_page;
int32 _reserved_3_;
int32 _reserved_4_;
int32 _reserved_5_;
};
struct _page_header_;
/*----------------------------------------------------------------*/
/*----- BPrintJob class ------------------------------------------*/
class BPrintJob {
public:
enum // These values are returned by PrinterType()
{
B_BW_PRINTER = 0,
B_COLOR_PRINTER
};
BPrintJob(const char *job_name);
virtual ~BPrintJob();
void BeginJob();
void CommitJob();
status_t ConfigJob();
void CancelJob();
status_t ConfigPage();
void SpoolPage();
bool CanContinue();
virtual void DrawView(BView *a_view, BRect a_rect, BPoint where);
BMessage *Settings() /* const */ ;
void SetSettings(BMessage *a_msg);
bool IsSettingsMessageValid(BMessage *a_msg) const;
BRect PaperRect();
BRect PrintableRect();
void GetResolution(int32 *xdpi, int32 *ydpi);
int32 FirstPage() /* const */ ;
int32 LastPage() /* const */ ;
int32 PrinterType(void * = NULL) const;
/*----- Private or reserved -----------------------------------------*/
private:
virtual void _ReservedPrintJob1();
virtual void _ReservedPrintJob2();
virtual void _ReservedPrintJob3();
virtual void _ReservedPrintJob4();
BPrintJob(const BPrintJob &);
BPrintJob &operator=(const BPrintJob &);
void RecurseView(BView *v, BPoint origin, BPicture *p, BRect r);
void MangleName(char *filename);
void HandlePageSetup(BMessage *setup);
bool HandlePrintSetup(BMessage *setup);
void NewPage();
void EndLastPage();
void AddSetupSpec();
void AddPicture(BPicture *picture, BRect *rect, BPoint where);
char* GetCurrentPrinterName() const;
void LoadDefaultSettings();
char * print_job_name;
int32 page_number;
BFile * spoolFile;
print_file_header current_header;
BRect paper_size;
BRect usable_size;
int pr_error;
char spool_file_name[256];
BMessage *setup_msg;
BMessage *default_setup_msg;
char stop_the_show;
int32 first_page;
int32 last_page;
short v_xres;
short v_yres;
_page_header_ * m_curPageHeader;
off_t m_curPageHeaderOffset;
uint32 _reserved[2];
};
/*-------------------------------------------------------------*/
/*-------------------------------------------------------------*/
#endif /* _PRINTSESSION_H */
+115
View File
@@ -0,0 +1,115 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: RadioButton.cpp
// Author: Marc Flerackers ([email protected])
// Description: BRadioButton represents a single on/off button. All
// sibling BRadioButton objects comprise a single
// "multiple choice" control.
//------------------------------------------------------------------------------
#ifndef _RADIO_BUTTON_H
#define _RADIO_BUTTON_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <Control.h>
#include <Bitmap.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
// BRadioButton class ----------------------------------------------------------
class BRadioButton : public BControl {
public:
BRadioButton(BRect frame,
const char *name,
const char *label,
BMessage *message,
uint32 resizMask = B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
BRadioButton(BMessage *archive);
virtual ~BRadioButton();
static BArchivable *Instantiate(BMessage *archive);
virtual status_t Archive(BMessage *archive, bool deep = true) const;
virtual void Draw(BRect updateRect);
virtual void MouseDown(BPoint point);
virtual void AttachedToWindow();
virtual void KeyDown(const char *bytes, int32 numBytes);
virtual void SetValue(int32 value);
virtual void GetPreferredSize(float *width, float *height);
virtual void ResizeToPreferred();
virtual status_t Invoke(BMessage *message = NULL);
virtual void MessageReceived(BMessage *message);
virtual void WindowActivated(bool active);
virtual void MouseUp(BPoint point);
virtual void MouseMoved(BPoint point, uint32 transit, const BMessage *message);
virtual void DetachedFromWindow();
virtual void FrameMoved(BPoint newLocation);
virtual void FrameResized(float width, float height);
virtual BHandler *ResolveSpecifier(BMessage *message,
int32 index,
BMessage *specifier,
int32 what,
const char *property);
virtual void MakeFocus(bool focused = true);
virtual void AllAttached();
virtual void AllDetached();
virtual status_t GetSupportedSuites(BMessage *message);
virtual status_t Perform(perform_code d, void *arg);
private:
friend status_t _init_interface_kit_();
virtual void _ReservedRadioButton1();
virtual void _ReservedRadioButton2();
BRadioButton &operator=(const BRadioButton &);
static BBitmap *sBitmaps[2][3];
bool fOutlined;
uint32 _reserved[2];
};
//------------------------------------------------------------------------------
#endif // _RADIO_BUTTON_H
/*
* $Log $
*
* $Id $
*
*/
+223
View File
@@ -0,0 +1,223 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Rect.h
// Author: Frans van Nispen ([email protected])
// Description: BRect represents a rectangular area.
//------------------------------------------------------------------------------
#ifndef _RECT_H
#define _RECT_H
// Standard Includes -----------------------------------------------------------
#include <math.h>
// System Includes -------------------------------------------------------------
#include <SupportDefs.h>
#include <Point.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
// BRect class -----------------------------------------------------------------
class BRect {
public:
float left;
float top;
float right;
float bottom;
BRect();
BRect(const BRect &r);
BRect(float l, float t, float r, float b);
BRect(BPoint lt, BPoint rb);
BRect &operator=(const BRect &r);
void Set(float l, float t, float r, float b);
void PrintToStream() const;
BPoint LeftTop() const;
BPoint RightBottom() const;
BPoint LeftBottom() const;
BPoint RightTop() const;
void SetLeftTop(const BPoint p);
void SetRightBottom(const BPoint p);
void SetLeftBottom(const BPoint p);
void SetRightTop(const BPoint p);
// transformation
void InsetBy(BPoint p);
void InsetBy(float dx, float dy);
void OffsetBy(BPoint p);
void OffsetBy(float dx, float dy);
void OffsetTo(BPoint p);
void OffsetTo(float x, float y);
// expression transformations
BRect & InsetBySelf(BPoint);
BRect & InsetBySelf(float dx, float dy);
BRect InsetByCopy(BPoint);
BRect InsetByCopy(float dx, float dy);
BRect & OffsetBySelf(BPoint);
BRect & OffsetBySelf(float dx, float dy);
BRect OffsetByCopy(BPoint);
BRect OffsetByCopy(float dx, float dy);
BRect & OffsetToSelf(BPoint);
BRect & OffsetToSelf(float dx, float dy);
BRect OffsetToCopy(BPoint);
BRect OffsetToCopy(float dx, float dy);
// comparison
bool operator==(BRect r) const;
bool operator!=(BRect r) const;
// intersection and union
BRect operator&(BRect r) const;
BRect operator|(BRect r) const;
bool Intersects(BRect r) const;
bool IsValid() const;
float Width() const;
int32 IntegerWidth() const;
float Height() const;
int32 IntegerHeight() const;
bool Contains(BPoint p) const;
bool Contains(BRect r) const;
};
//------------------------------------------------------------------------------
// inline definitions ----------------------------------------------------------
inline BPoint BRect::LeftTop() const
{
return(*((const BPoint*)&left));
}
inline BPoint BRect::RightBottom() const
{
return(*((const BPoint*)&right));
}
inline BPoint BRect::LeftBottom() const
{
return(BPoint(left, bottom));
}
inline BPoint BRect::RightTop() const
{
return(BPoint(right, top));
}
inline BRect::BRect()
{
top = left = 0;
bottom = right = -1;
}
inline BRect::BRect(float l, float t, float r, float b)
{
left = l;
top = t;
right = r;
bottom = b;
}
inline BRect::BRect(const BRect &r)
{
left = r.left;
top = r.top;
right = r.right;
bottom = r.bottom;
}
inline BRect::BRect(BPoint leftTop, BPoint rightBottom)
{
left = leftTop.x;
top = leftTop.y;
right = rightBottom.x;
bottom = rightBottom.y;
}
inline BRect &BRect::operator=(const BRect& from)
{
left = from.left;
top = from.top;
right = from.right;
bottom = from.bottom;
return *this;
}
inline void BRect::Set(float l, float t, float r, float b)
{
left = l;
top = t;
right = r;
bottom = b;
}
inline bool BRect::IsValid() const
{
if (left <= right && top <= bottom)
return true;
else
return false;
}
inline int32 BRect::IntegerWidth() const
{
return((int32)ceil(right - left));
}
inline float BRect::Width() const
{
return(right - left);
}
inline int32 BRect::IntegerHeight() const
{
return((int32)ceil(bottom - top));
}
inline float BRect::Height() const
{
return(bottom - top);
}
//------------------------------------------------------------------------------
#endif // _RECT_H
/*
* $Log $
*
* $Id $
*
*/
+141
View File
@@ -0,0 +1,141 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: StatusBar.h
// Author: Marc Flerackers ([email protected])
// Description: BStatusBar displays a "percentage-of-completion" gauge.
//------------------------------------------------------------------------------
#ifndef _STATUS_BAR_H
#define _STATUS_BAR_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <View.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
// BStatusBar class ------------------------------------------------------------
class BStatusBar : public BView
{
public:
BStatusBar(BRect frame, const char *name, const char *label = NULL,
const char *trailingLabel = NULL);
BStatusBar(BMessage *archive);
virtual ~BStatusBar();
static BArchivable *Instantiate(BMessage *archive);
virtual status_t Archive(BMessage *archive, bool deep = true) const;
virtual void AttachedToWindow();
virtual void MessageReceived(BMessage *message);
virtual void Draw(BRect updateRect);
virtual void SetBarColor(rgb_color color);
virtual void SetBarHeight(float height);
virtual void SetText(const char *string);
virtual void SetTrailingText(const char *string);
virtual void SetMaxValue(float max);
void Update(float delta, const char *text = NULL, const char *trailingText = NULL);
virtual void Reset(const char *label = NULL, const char *trailingLabel = NULL);
float CurrentValue() const;
float MaxValue() const;
rgb_color BarColor() const;
float BarHeight() const;
const char *Text() const;
const char *TrailingText() const;
const char *Label() const;
const char *TrailingLabel() const;
virtual void MouseDown(BPoint point);
virtual void MouseUp(BPoint point);
virtual void WindowActivated(bool state);
virtual void MouseMoved(BPoint point, uint32 transit, const BMessage *message);
virtual void DetachedFromWindow();
virtual void FrameMoved(BPoint new_position);
virtual void FrameResized(float new_width, float new_height);
virtual BHandler *ResolveSpecifier(BMessage *message, int32 index, BMessage *specifier,
int32 what, const char *property);
virtual void ResizeToPreferred();
virtual void GetPreferredSize(float *width, float *height);
virtual void MakeFocus(bool state = true);
virtual void AllAttached();
virtual void AllDetached();
virtual status_t GetSupportedSuites(BMessage *data);
virtual status_t Perform(perform_code d, void *arg);
private:
virtual void _ReservedStatusBar1();
virtual void _ReservedStatusBar2();
virtual void _ReservedStatusBar3();
virtual void _ReservedStatusBar4();
BStatusBar &operator=(const BStatusBar &);
void InitObject(const char *l, const char *aux_l);
void SetTextData(char **pp, const char *str);
void FillBar(BRect r);
void Resize();
void _Draw(BRect updateRect, bool bar_only);
char *fLabel;
char *fTrailingLabel;
char *fText;
char *fTrailingText;
float fMax;
float fCurrent;
float fBarHeight;
float fTrailingWidth;
rgb_color fBarColor;
float fEraseText;
float fEraseTrailingText;
bool fCustomBarHeight;
bool _pad1;
bool _pad2;
bool _pad3;
uint32 _reserved[3];
};
//------------------------------------------------------------------------------
#endif // _STATUS_BAR_H
/*
* $Log $
*
* $Id $
*
*/
+55
View File
@@ -0,0 +1,55 @@
////////////////////////////////////////////////////////////////////////////////
//
// File: StringItem.h
//
// Description:
//
// Copyright 2001, Ulrich Wimboeck
//
////////////////////////////////////////////////////////////////////////////////
#ifndef _STRING_ITEM_H
#define _STRING_ITEM_H
#include <ListItem.h>
#ifdef USE_OPENBEOS_NAMESPACE
namespace OpenBeOS
{
#endif
/*----------------------------------------------------------------*/
/*----- BStringItem class ----------------------------------------*/
class BStringItem : public BListItem
{
public:
BStringItem(const char* text, uint32 outlineLevel = 0, bool expanded = true) ;
BStringItem(BMessage* data) ;
virtual ~MyStringItem() ;
static BArchivable *Instantiate(BMessage* data);
virtual status_t Archive(BMessage* data, bool deep = true) const ;
virtual void DrawItem(BView* owner, BRect frame, bool complete = false) ;
virtual void SetText(const char* text) ;
const char* Text() const ;
virtual void Update(BView* owner, const BFont* font) ;
virtual status_t Perform(perform_code d, void* arg);
private:
BStringItem(const BStringItem &) ;
BStringItem& operator=(const BStringItem &) ;
char* fText;
float fBaselineOffset ;
} ;
#ifdef USE_OPENBEOS_NAMESPACE
}
#endif
#endif /* _STRING_ITEM_H */
+107
View File
@@ -0,0 +1,107 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: StringView.h
// Author: Frans van Nispen ([email protected])
// Description: BStringView draw a non-editable text string
//------------------------------------------------------------------------------
#ifndef _STRING_VIEW_H
#define _STRING_VIEW_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <View.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
// BStringView class -----------------------------------------------------------
class BStringView : public BView{
public:
BStringView(BRect bounds, const char* name, const char* text,
uint32 resizeFlags = B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW);
BStringView(BMessage* data);
virtual ~BStringView();
static BArchivable *Instantiate(BMessage* data);
virtual status_t Archive(BMessage* data, bool deep = true) const;
void SetText(const char* text);
const char *Text() const;
void SetAlignment(alignment flag);
alignment Alignment() const;
virtual void AttachedToWindow();
virtual void Draw(BRect bounds);
virtual void MessageReceived(BMessage* msg);
virtual void MouseDown(BPoint pt);
virtual void MouseUp(BPoint pt);
virtual void MouseMoved(BPoint pt, uint32 code, const BMessage* msg);
virtual void DetachedFromWindow();
virtual void FrameMoved(BPoint new_position);
virtual void FrameResized(float new_width, float new_height);
virtual BHandler *ResolveSpecifier( BMessage* msg, int32 index, BMessage* specifier,
int32 form, const char* property);
virtual void ResizeToPreferred();
virtual void GetPreferredSize(float* width, float* height);
virtual void MakeFocus(bool state = true);
virtual void AllAttached();
virtual void AllDetached();
virtual status_t GetSupportedSuites(BMessage* data);
// Private or reserved ---------------------------------------------------------
virtual status_t Perform(perform_code d, void* arg);
private:
virtual void _ReservedStringView1();
virtual void _ReservedStringView2();
virtual void _ReservedStringView3();
BStringView &operator=(const BStringView&);
char* fText;
alignment fAlign;
uint32 _reserved[3];
};
//------------------------------------------------------------------------------
#endif // _STRINGVIEW_H
/*
* $Log $
*
* $Id $
*
*/
+145
View File
@@ -0,0 +1,145 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: TextControl.h
// Author: Frans van Nispen ([email protected])
// Description: BTextControl displays text that can act like a control.
//------------------------------------------------------------------------------
#ifndef _TEXT_CONTROL_H
#define _TEXT_CONTROL_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <Control.h>
#include <InterfaceDefs.h>
#include <TextView.h> // For convenience
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class _BTextInput_;
// BTextControl class -----------------------------------------------------------
class BTextControl : public BControl {
public:
BTextControl(BRect frame, const char* name,
const char* label,
const char* initial_text, BMessage* message,
uint32 rmask = B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
virtual ~BTextControl();
BTextControl(BMessage* data);
static BArchivable *Instantiate(BMessage* data);
virtual status_t Archive(BMessage* data, bool deep = true) const;
virtual void SetText(const char* text);
const char* Text() const;
virtual void SetValue(int32 value);
virtual status_t Invoke(BMessage* msg = NULL);
BTextView* TextView() const;
virtual void SetModificationMessage(BMessage* message);
BMessage* ModificationMessage() const;
virtual void SetAlignment(alignment label, alignment text);
void GetAlignment(alignment* label, alignment* text) const;
virtual void SetDivider(float dividing_line);
float Divider() const;
virtual void Draw(BRect updateRect);
virtual void MouseDown(BPoint where);
virtual void AttachedToWindow();
virtual void MakeFocus(bool focusState = true);
virtual void SetEnabled(bool state);
virtual void FrameMoved(BPoint new_position);
virtual void FrameResized(float new_width, float new_height);
virtual void WindowActivated(bool active);
virtual void GetPreferredSize(float* width, float* height);
virtual void ResizeToPreferred();
virtual void MessageReceived(BMessage* msg);
virtual BHandler *ResolveSpecifier(BMessage* msg, int32 index,
BMessage* specifier, int32 form,
const char* property);
virtual void MouseUp(BPoint pt);
virtual void MouseMoved(BPoint pt, uint32 code,
const BMessage* msg);
virtual void DetachedFromWindow();
virtual void AllAttached();
virtual void AllDetached();
virtual status_t GetSupportedSuites(BMessage* data);
virtual void SetFlags(uint32 flags);
// Private or reserved ---------------------------------------------------------
virtual status_t Perform(perform_code d, void* arg);
private:
friend class _BTextInput_;
virtual void _ReservedTextControl1();
virtual void _ReservedTextControl2();
virtual void _ReservedTextControl3();
virtual void _ReservedTextControl4();
BTextControl& operator=(const BTextControl&);
// this one is not defined, so I guess I am on my own here
_BTextInput_* fText;
char* fUnusedCharP; //fLabel; // this is in BControl
BMessage* fModificationMessage;
alignment fLabelAlign;
float fDivider;
// uint16 fPrevWidth;
// uint16 fPrevHeight;
uint32 _reserved[4];
#if !_PR3_COMPATIBLE_
uint32 _more_reserved[4];
#endif
// bool fClean;
bool fSkipSetFlags; // will use this for SHIFT-TAB
bool fUnusedBool1;
bool fUnusedBool2;
};
//------------------------------------------------------------------------------
#endif // _TEXTCONTROL_H
/*
* $Log $
*
* $Id $
*
*/
+125
View File
@@ -0,0 +1,125 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: UnicodeBlockObjects.h
// Author: Erik Jaesler ([email protected])
// Description: Predefined unicode_block objects
//------------------------------------------------------------------------------
#ifndef _UNICODEBLOCKOBJECTS_H
#define _UNICODEBLOCKOBJECTS_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <Font.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
// Unicode block list with their unicode encoding range
const unicode_block B_BASIC_LATIN_BLOCK( /* 0000 - 007F */ 0x0000000000000000LL, 0x0000000000000001LL);
const unicode_block B_LATIN1_SUPPLEMENT_BLOCK( /* 0080 - 00FF */ 0x0000000000000000LL, 0x0000000000000002LL);
const unicode_block B_LATIN_EXTENDED_A_BLOCK( /* 0100 - 017F */ 0x0000000000000000LL, 0x0000000000000004LL);
const unicode_block B_LATIN_EXTENDED_B_BLOCK( /* 0180 - 024F */ 0x0000000000000000LL, 0x0000000000000008LL);
const unicode_block B_IPA_EXTENSIONS_BLOCK( /* 0250 - 02AF */ 0x0000000000000000LL, 0x0000000000000010LL);
const unicode_block B_SPACING_MODIFIER_LETTERS_BLOCK( /* 02B0 - 02FF */ 0x0000000000000000LL, 0x0000000000000020LL);
const unicode_block B_COMBINING_DIACRITICAL_MARKS_BLOCK( /* 0300 - 036F */ 0x0000000000000000LL, 0x0000000000000040LL);
const unicode_block B_BASIC_GREEK_BLOCK( /* 0370 - 03CF */ 0x0000000000000000LL, 0x0000000000000080LL);
const unicode_block B_GREEK_SYMBOLS_AND_COPTIC_BLOCK( /* 03D0 - 03FF */ 0x0000000000000000LL, 0x0000000000000100LL);
const unicode_block B_CYRILLIC_BLOCK( /* 0400 - 04FF */ 0x0000000000000000LL, 0x0000000000000200LL);
const unicode_block B_ARMENIAN_BLOCK( /* 0530 - 058F */ 0x0000000000000000LL, 0x0000000000000400LL);
const unicode_block B_BASIC_HEBREW_BLOCK( /* 0590 - 05CF */ 0x0000000000000000LL, 0x0000000000000800LL);
const unicode_block B_HEBREW_EXTENDED_BLOCK( /* 05D0 - 05FF */ 0x0000000000000000LL, 0x0000000000001000LL);
const unicode_block B_BASIC_ARABIC_BLOCK( /* 0600 - 0670 */ 0x0000000000000000LL, 0x0000000000002000LL);
const unicode_block B_ARABIC_EXTENDED_BLOCK( /* 0671 - 06FF */ 0x0000000000000000LL, 0x0000000000004000LL);
const unicode_block B_DEVANAGARI_BLOCK( /* 0900 - 097F */ 0x0000000000000000LL, 0x0000000000008000LL);
const unicode_block B_BENGALI_BLOCK( /* 0980 - 09FF */ 0x0000000000000000LL, 0x0000000000010000LL);
const unicode_block B_GURMUKHI_BLOCK( /* 0A00 - 0A7F */ 0x0000000000000000LL, 0x0000000000020000LL);
const unicode_block B_GUJARATI_BLOCK( /* 0A80 - 0AFF */ 0x0000000000000000LL, 0x0000000000040000LL);
const unicode_block B_ORIYA_BLOCK( /* 0B00 - 0B7F */ 0x0000000000000000LL, 0x0000000000080000LL);
const unicode_block B_TAMIL_BLOCK( /* 0B80 - 0BFF */ 0x0000000000000000LL, 0x0000000000100000LL);
const unicode_block B_TELUGU_BLOCK( /* 0C00 - 0C7F */ 0x0000000000000000LL, 0x0000000000200000LL);
const unicode_block B_KANNADA_BLOCK( /* 0C80 - 0CFF */ 0x0000000000000000LL, 0x0000000000400000LL);
const unicode_block B_MALAYALAM_BLOCK( /* 0D00 - 0D7F */ 0x0000000000000000LL, 0x0000000000800000LL);
const unicode_block B_THAI_BLOCK( /* 0E00 - 0E7F */ 0x0000000000000000LL, 0x0000000001000000LL);
const unicode_block B_LAO_BLOCK( /* 0E80 - 0EFF */ 0x0000000000000000LL, 0x0000000002000000LL);
const unicode_block B_BASIC_GEORGIAN_BLOCK( /* 10A0 - 10CF */ 0x0000000000000000LL, 0x0000000004000000LL);
const unicode_block B_GEORGIAN_EXTENDED_BLOCK( /* 10D0 - 10FF */ 0x0000000000000000LL, 0x0000000008000000LL);
const unicode_block B_HANGUL_JAMO_BLOCK( /* 1100 - 11FF */ 0x0000000000000000LL, 0x0000000010000000LL);
const unicode_block B_LATIN_EXTENDED_ADDITIONAL_BLOCK( /* 1E00 - 1EFF */ 0x0000000000000000LL, 0x0000000020000000LL);
const unicode_block B_GREEK_EXTENDED_BLOCK( /* 1F00 - 1FFF */ 0x0000000000000000LL, 0x0000000040000000LL);
const unicode_block B_GENERAL_PUNCTUATION_BLOCK( /* 2000 - 206F */ 0x0000000000000000LL, 0x0000000080000000LL);
const unicode_block B_SUPERSCRIPTS_AND_SUBSCRIPTS_BLOCK( /* 2070 - 209F */ 0x0000000000000000LL, 0x0000000100000000LL);
const unicode_block B_CURRENCY_SYMBOLS_BLOCK( /* 20A0 - 20CF */ 0x0000000000000000LL, 0x0000000200000000LL);
const unicode_block B_COMBINING_MARKS_FOR_SYMBOLS_BLOCK( /* 20D0 - 20FF */ 0x0000000000000000LL, 0x0000000400000000LL);
const unicode_block B_LETTERLIKE_SYMBOLS_BLOCK( /* 2100 - 214F */ 0x0000000000000000LL, 0x0000000800000000LL);
const unicode_block B_NUMBER_FORMS_BLOCK( /* 2150 - 218F */ 0x0000000000000000LL, 0x0000001000000000LL);
const unicode_block B_ARROWS_BLOCK( /* 2190 - 21FF */ 0x0000000000000000LL, 0x0000002000000000LL);
const unicode_block B_MATHEMATICAL_OPERATORS_BLOCK( /* 2200 - 22FF */ 0x0000000000000000LL, 0x0000004000000000LL);
const unicode_block B_MISCELLANEOUS_TECHNICAL_BLOCK( /* 2300 - 23FF */ 0x0000000000000000LL, 0x0000008000000000LL);
const unicode_block B_CONTROL_PICTURES_BLOCK( /* 2400 - 243F */ 0x0000000000000000LL, 0x0000010000000000LL);
const unicode_block B_OPTICAL_CHARACTER_RECOGNITION_BLOCK( /* 2440 - 245F */ 0x0000000000000000LL, 0x0000020000000000LL);
const unicode_block B_ENCLOSED_ALPHANUMERICS_BLOCK( /* 2460 - 24FF */ 0x0000000000000000LL, 0x0000040000000000LL);
const unicode_block B_BOX_DRAWING_BLOCK( /* 2500 - 257F */ 0x0000000000000000LL, 0x0000080000000000LL);
const unicode_block B_BLOCK_ELEMENTS_BLOCK( /* 2580 - 259F */ 0x0000000000000000LL, 0x0000100000000000LL);
const unicode_block B_GEOMETRIC_SHAPES_BLOCK( /* 25A0 - 25FF */ 0x0000000000000000LL, 0x0000200000000000LL);
const unicode_block B_MISCELLANEOUS_SYMBOLS_BLOCK( /* 2600 - 26FF */ 0x0000000000000000LL, 0x0000400000000000LL);
const unicode_block B_DINGBATS_BLOCK( /* 2700 - 27BF */ 0x0000000000000000LL, 0x0000800000000000LL);
const unicode_block B_CJK_SYMBOLS_AND_PUNCTUATION_BLOCK( /* 3000 - 303F */ 0x0000000000000000LL, 0x0001000000000000LL);
const unicode_block B_HIRAGANA_BLOCK( /* 3040 - 309F */ 0x0000000000000000LL, 0x0002000000000000LL);
const unicode_block B_KATAKANA_BLOCK( /* 30A0 - 30FF */ 0x0000000000000000LL, 0x0004000000000000LL);
const unicode_block B_BOPOMOFO_BLOCK( /* 3100 - 312F */ 0x0000000000000000LL, 0x0008000000000000LL);
const unicode_block B_HANGUL_COMPATIBILITY_JAMO_BLOCK( /* 3130 - 318F */ 0x0000000000000000LL, 0x0010000000000000LL);
const unicode_block B_CJK_MISCELLANEOUS_BLOCK( /* 3190 - 319F */ 0x0000000000000000LL, 0x0020000000000000LL);
const unicode_block B_ENCLOSED_CJK_LETTERS_AND_MONTHS_BLOCK(/* 3200 - 32FF */ 0x0000000000000000LL, 0x0040000000000000LL);
const unicode_block B_CJK_COMPATIBILITY_BLOCK( /* 3300 - 33FF */ 0x0000000000000000LL, 0x0080000000000000LL);
const unicode_block B_HANGUL_BLOCK( /* AC00 - D7AF */ 0x0000000000000000LL, 0x0100000000000000LL);
const unicode_block B_HIGH_SURROGATES_BLOCK( /* D800 - DBFF */ 0x0000000000000000LL, 0x0200000000000000LL);
const unicode_block B_LOW_SURROGATES_BLOCK( /* DC00 - DFFF */ 0x0000000000000000LL, 0x0400000000000000LL);
const unicode_block B_CJK_UNIFIED_IDEOGRAPHS_BLOCK( /* 4E00 - 9FFF */ 0x0000000000000000LL, 0x0800000000000000LL);
const unicode_block B_PRIVATE_USE_AREA_BLOCK( /* E000 - F8FF */ 0x0000000000000000LL, 0x1000000000000000LL);
const unicode_block B_CJK_COMPATIBILITY_IDEOGRAPHS_BLOCK( /* F900 - FAFF */ 0x0000000000000000LL, 0x2000000000000000LL);
const unicode_block B_ALPHABETIC_PRESENTATION_FORMS_BLOCK( /* FB00 - FB4F */ 0x0000000000000000LL, 0x4000000000000000LL);
const unicode_block B_ARABIC_PRESENTATION_FORMS_A_BLOCK( /* FB50 - FDFF */ 0x0000000000000000LL, 0x8000000000000000LL);
const unicode_block B_COMBINING_HALF_MARKS_BLOCK( /* FE20 - FE2F */ 0x0000000000000001LL, 0x0000000000000000LL);
const unicode_block B_CJK_COMPATIBILITY_FORMS_BLOCK( /* FE30 - FE4F */ 0x0000000000000002LL, 0x0000000000000000LL);
const unicode_block B_SMALL_FORM_VARIANTS_BLOCK( /* FE50 - FE6F */ 0x0000000000000004LL, 0x0000000000000000LL);
const unicode_block B_ARABIC_PRESENTATION_FORMS_B_BLOCK( /* FE70 - FEFE */ 0x0000000000000008LL, 0x0000000000000000LL);
const unicode_block B_HALFWIDTH_AND_FULLWIDTH_FORMS_BLOCK( /* FF00 - FFEF */ 0x0000000000000010LL, 0x0000000000000000LL);
const unicode_block B_SPECIALS_BLOCK( /* FEFF and FFF0 - FFFF */ 0x0000000000000020LL, 0x0000000000000000LL);
const unicode_block B_TIBETAN_BLOCK( /* 0F00 - 0FBF */ 0x0000000000000040LL, 0x0000000000000000LL);
#endif // _UNICODEBLOCKOBJECTS_H
/*
* $Log $
*
* $Id $
*
*/
+667
View File
@@ -0,0 +1,667 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: View.h
// Author: Erik Jaesler ([email protected])
// Description: BView is the base class for all views (clipped regions
// within a window).
//------------------------------------------------------------------------------
#ifndef _VIEW_H
#define _VIEW_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <Font.h>
#include <Handler.h>
#include <InterfaceDefs.h>
#include <Rect.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
// view definitions ------------------------------------------------------------
enum {
B_PRIMARY_MOUSE_BUTTON = 0x01,
B_SECONDARY_MOUSE_BUTTON = 0x02,
B_TERTIARY_MOUSE_BUTTON = 0x04
};
enum {
B_ENTERED_VIEW = 0,
B_INSIDE_VIEW,
B_EXITED_VIEW,
B_OUTSIDE_VIEW
};
enum {
B_POINTER_EVENTS = 0x00000001,
B_KEYBOARD_EVENTS = 0x00000002
};
enum {
B_LOCK_WINDOW_FOCUS = 0x00000001,
B_SUSPEND_VIEW_FOCUS = 0x00000002,
B_NO_POINTER_HISTORY = 0x00000004
};
enum {
B_TRACK_WHOLE_RECT,
B_TRACK_RECT_CORNER
};
enum {
B_FONT_FAMILY_AND_STYLE = 0x00000001,
B_FONT_SIZE = 0x00000002,
B_FONT_SHEAR = 0x00000004,
B_FONT_ROTATION = 0x00000008,
B_FONT_SPACING = 0x00000010,
B_FONT_ENCODING = 0x00000020,
B_FONT_FACE = 0x00000040,
B_FONT_FLAGS = 0x00000080,
B_FONT_ALL = 0x000000FF
};
const uint32 B_FULL_UPDATE_ON_RESIZE = 0x80000000UL; /* 31 */
const uint32 _B_RESERVED1_ = 0x40000000UL; /* 30 */
const uint32 B_WILL_DRAW = 0x20000000UL; /* 29 */
const uint32 B_PULSE_NEEDED = 0x10000000UL; /* 28 */
const uint32 B_NAVIGABLE_JUMP = 0x08000000UL; /* 27 */
const uint32 B_FRAME_EVENTS = 0x04000000UL; /* 26 */
const uint32 B_NAVIGABLE = 0x02000000UL; /* 25 */
const uint32 B_SUBPIXEL_PRECISE = 0x01000000UL; /* 24 */
const uint32 B_DRAW_ON_CHILDREN = 0x00800000UL; /* 23 */
const uint32 B_INPUT_METHOD_AWARE = 0x00400000UL; /* 23 */
const uint32 _B_RESERVED7_ = 0x00200000UL; /* 22 */
#define _RESIZE_MASK_ ~(B_FULL_UPDATE_ON_RESIZE|_B_RESERVED1_|B_WILL_DRAW|\
B_PULSE_NEEDED|B_NAVIGABLE_JUMP|B_FRAME_EVENTS|B_NAVIGABLE|\
B_SUBPIXEL_PRECISE|B_DRAW_ON_CHILDREN|B_INPUT_METHOD_AWARE|_B_RESERVED7_)
const uint32 _VIEW_TOP_ = 1UL;
const uint32 _VIEW_LEFT_ = 2UL;
const uint32 _VIEW_BOTTOM_ = 3UL;
const uint32 _VIEW_RIGHT_ = 4UL;
const uint32 _VIEW_CENTER_ = 5UL;
inline uint32 _rule_(uint32 r1, uint32 r2, uint32 r3, uint32 r4)
{ return ((r1 << 12) | (r2 << 8) | (r3 << 4) | r4); }
#define B_FOLLOW_NONE 0
#define B_FOLLOW_ALL_SIDES _rule_(_VIEW_TOP_, _VIEW_LEFT_, _VIEW_BOTTOM_,\
_VIEW_RIGHT_)
#define B_FOLLOW_ALL B_FOLLOW_ALL_SIDES
#define B_FOLLOW_LEFT _rule_(0, _VIEW_LEFT_, 0, _VIEW_LEFT_)
#define B_FOLLOW_RIGHT _rule_(0, _VIEW_RIGHT_, 0, _VIEW_RIGHT_)
#define B_FOLLOW_LEFT_RIGHT _rule_(0, _VIEW_LEFT_, 0, _VIEW_RIGHT_)
#define B_FOLLOW_H_CENTER _rule_(0, _VIEW_CENTER_, 0, _VIEW_CENTER_)
#define B_FOLLOW_TOP _rule_(_VIEW_TOP_, 0, _VIEW_TOP_, 0)
#define B_FOLLOW_BOTTOM _rule_(_VIEW_BOTTOM_, 0, _VIEW_BOTTOM_, 0)
#define B_FOLLOW_TOP_BOTTOM _rule_(_VIEW_TOP_, 0, _VIEW_BOTTOM_, 0)
#define B_FOLLOW_V_CENTER _rule_(_VIEW_CENTER_, 0, _VIEW_CENTER_, 0)
class BBitmap;
class BCursor;
class BMessage;
class BPicture;
class BPolygon;
class BRegion;
class BScrollBar;
class BScrollView;
class BShape;
class BShelf;
class BString;
class BWindow;
struct _view_attr_;
struct _array_data_;
struct _array_hdr_;
struct overlay_restrictions;
// BView class -----------------------------------------------------------------
class BView : public BHandler {
public:
BView(BRect frame, const char* name,
uint32 resizeMask, uint32 flags);
virtual ~BView();
BView(BMessage* data);
static BArchivable* Instantiate(BMessage* data);
virtual status_t Archive(BMessage* data, bool deep = true) const;
virtual void AttachedToWindow();
virtual void AllAttached();
virtual void DetachedFromWindow();
virtual void AllDetached();
virtual void MessageReceived(BMessage* msg);
void AddChild(BView* child, BView* before = NULL);
bool RemoveChild(BView* child);
int32 CountChildren() const;
BView* ChildAt(int32 index) const;
BView* NextSibling() const;
BView* PreviousSibling() const;
bool RemoveSelf();
BWindow *Window() const;
virtual void Draw(BRect updateRect);
virtual void MouseDown(BPoint where);
virtual void MouseUp(BPoint where);
virtual void MouseMoved(BPoint where,
uint32 code,
const BMessage* a_message);
virtual void WindowActivated(bool state);
virtual void KeyDown(const char* bytes, int32 numBytes);
virtual void KeyUp(const char* bytes, int32 numBytes);
virtual void Pulse();
virtual void FrameMoved(BPoint new_position);
virtual void FrameResized(float new_width, float new_height);
virtual void TargetedByScrollView(BScrollView* scroll_view);
void BeginRectTracking(BRect startRect,
uint32 style = B_TRACK_WHOLE_RECT);
void EndRectTracking();
void GetMouse(BPoint* location,
uint32* buttons,
bool checkMessageQueue = true);
void DragMessage(BMessage* aMessage,
BRect dragRect,
BHandler* reply_to = NULL);
void DragMessage(BMessage* aMessage,
BBitmap* anImage,
BPoint offset,
BHandler* reply_to = NULL);
void DragMessage(BMessage* aMessage,
BBitmap* anImage,
drawing_mode dragMode,
BPoint offset,
BHandler* reply_to = NULL);
BView* FindView(const char* name) const;
BView* Parent() const;
BRect Bounds() const;
BRect Frame() const;
void ConvertToScreen(BPoint* pt) const;
BPoint ConvertToScreen(BPoint pt) const;
void ConvertFromScreen(BPoint* pt) const;
BPoint ConvertFromScreen(BPoint pt) const;
void ConvertToScreen(BRect* r) const;
BRect ConvertToScreen(BRect r) const;
void ConvertFromScreen(BRect* r) const;
BRect ConvertFromScreen(BRect r) const;
void ConvertToParent(BPoint* pt) const;
BPoint ConvertToParent(BPoint pt) const;
void ConvertFromParent(BPoint* pt) const;
BPoint ConvertFromParent(BPoint pt) const;
void ConvertToParent(BRect* r) const;
BRect ConvertToParent(BRect r) const;
void ConvertFromParent(BRect* r) const;
BRect ConvertFromParent(BRect r) const;
BPoint LeftTop() const;
void GetClippingRegion(BRegion* region) const;
virtual void ConstrainClippingRegion(BRegion* region);
void ClipToPicture(BPicture* picture,
BPoint where = B_ORIGIN,
bool sync = true);
void ClipToInversePicture(BPicture* picture,
BPoint where = B_ORIGIN,
bool sync = true);
virtual void SetDrawingMode(drawing_mode mode);
drawing_mode DrawingMode() const;
void SetBlendingMode(source_alpha srcAlpha,
alpha_function alphaFunc);
void GetBlendingMode(source_alpha* srcAlpha,
alpha_function* alphaFunc) const;
virtual void SetPenSize(float size);
float PenSize() const;
void SetViewCursor(const BCursor* cursor, bool sync=true);
virtual void SetViewColor(rgb_color c);
void SetViewColor(uchar r, uchar g, uchar b, uchar a = 255);
rgb_color ViewColor() const;
void SetViewBitmap(const BBitmap* bitmap,
BRect srcRect, BRect dstRect,
uint32 followFlags = B_FOLLOW_TOP|B_FOLLOW_LEFT,
uint32 options = B_TILE_BITMAP);
void SetViewBitmap(const BBitmap* bitmap,
uint32 followFlags = B_FOLLOW_TOP|B_FOLLOW_LEFT,
uint32 options = B_TILE_BITMAP);
void ClearViewBitmap();
status_t SetViewOverlay(const BBitmap* overlay,
BRect srcRect, BRect dstRect,
rgb_color* colorKey,
uint32 followFlags = B_FOLLOW_TOP|B_FOLLOW_LEFT,
uint32 options = 0);
status_t SetViewOverlay(const BBitmap* overlay, rgb_color* colorKey,
uint32 followFlags = B_FOLLOW_TOP|B_FOLLOW_LEFT,
uint32 options = 0);
void ClearViewOverlay();
virtual void SetHighColor(rgb_color a_color);
void SetHighColor(uchar r, uchar g, uchar b, uchar a = 255);
rgb_color HighColor() const;
virtual void SetLowColor(rgb_color a_color);
void SetLowColor(uchar r, uchar g, uchar b, uchar a = 255);
rgb_color LowColor() const;
void SetLineMode(cap_mode lineCap,
join_mode lineJoin,
float miterLimit = B_DEFAULT_MITER_LIMIT);
join_mode LineJoinMode() const;
cap_mode LineCapMode() const;
float LineMiterLimit() const;
void SetOrigin(BPoint pt);
void SetOrigin(float x, float y);
BPoint Origin() const;
void PushState();
void PopState();
void MovePenTo(BPoint pt);
void MovePenTo(float x, float y);
void MovePenBy(float x, float y);
BPoint PenLocation() const;
void StrokeLine(BPoint toPt,
pattern p = B_SOLID_HIGH);
void StrokeLine(BPoint pt0,
BPoint pt1,
pattern p = B_SOLID_HIGH);
void BeginLineArray(int32 count);
void AddLine(BPoint pt0, BPoint pt1, rgb_color col);
void EndLineArray();
void StrokePolygon(const BPolygon* aPolygon,
bool closed = true,
pattern p = B_SOLID_HIGH);
void StrokePolygon(const BPoint* ptArray,
int32 numPts,
bool closed = true,
pattern p = B_SOLID_HIGH);
void StrokePolygon(const BPoint* ptArray,
int32 numPts,
BRect bounds,
bool closed = true,
pattern p = B_SOLID_HIGH);
void FillPolygon(const BPolygon* aPolygon,
pattern p = B_SOLID_HIGH);
void FillPolygon(const BPoint* ptArray,
int32 numPts,
pattern p = B_SOLID_HIGH);
void FillPolygon(const BPoint* ptArray,
int32 numPts,
BRect bounds,
pattern p = B_SOLID_HIGH);
void StrokeTriangle(BPoint pt1,
BPoint pt2,
BPoint pt3,
BRect bounds,
pattern p = B_SOLID_HIGH);
void StrokeTriangle(BPoint pt1,
BPoint pt2,
BPoint pt3,
pattern p = B_SOLID_HIGH);
void FillTriangle(BPoint pt1,
BPoint pt2,
BPoint pt3,
pattern p = B_SOLID_HIGH);
void FillTriangle(BPoint pt1,
BPoint pt2,
BPoint pt3,
BRect bounds,
pattern p = B_SOLID_HIGH);
void StrokeRect(BRect r, pattern p = B_SOLID_HIGH);
void FillRect(BRect r, pattern p = B_SOLID_HIGH);
void FillRegion(BRegion* a_region, pattern p= B_SOLID_HIGH);
void InvertRect(BRect r);
void StrokeRoundRect(BRect r,
float xRadius,
float yRadius,
pattern p = B_SOLID_HIGH);
void FillRoundRect(BRect r,
float xRadius,
float yRadius,
pattern p = B_SOLID_HIGH);
void StrokeEllipse(BPoint center,
float xRadius,
float yRadius,
pattern p = B_SOLID_HIGH);
void StrokeEllipse(BRect r, pattern p = B_SOLID_HIGH);
void FillEllipse(BPoint center,
float xRadius,
float yRadius,
pattern p = B_SOLID_HIGH);
void FillEllipse(BRect r, pattern p = B_SOLID_HIGH);
void StrokeArc(BPoint center,
float xRadius,
float yRadius,
float start_angle,
float arc_angle,
pattern p = B_SOLID_HIGH);
void StrokeArc(BRect r,
float start_angle,
float arc_angle,
pattern p = B_SOLID_HIGH);
void FillArc(BPoint center,
float xRadius,
float yRadius,
float start_angle,
float arc_angle,
pattern p = B_SOLID_HIGH);
void FillArc(BRect r,
float start_angle,
float arc_angle,
pattern p = B_SOLID_HIGH);
void StrokeBezier(BPoint* controlPoints,
pattern p = B_SOLID_HIGH);
void FillBezier(BPoint* controlPoints,
pattern p = B_SOLID_HIGH);
void StrokeShape(BShape* shape,
pattern p = B_SOLID_HIGH);
void FillShape(BShape* shape,
pattern p = B_SOLID_HIGH);
void CopyBits(BRect src, BRect dst);
void DrawBitmapAsync(const BBitmap* aBitmap,
BRect srcRect,
BRect dstRect);
void DrawBitmapAsync(const BBitmap* aBitmap);
void DrawBitmapAsync(const BBitmap* aBitmap, BPoint where);
void DrawBitmapAsync(const BBitmap* aBitmap, BRect dstRect);
void DrawBitmap(const BBitmap* aBitmap,
BRect srcRect,
BRect dstRect);
void DrawBitmap(const BBitmap* aBitmap);
void DrawBitmap(const BBitmap* aBitmap, BPoint where);
void DrawBitmap(const BBitmap* aBitmap, BRect dstRect);
void DrawChar(char aChar);
void DrawChar(char aChar, BPoint location);
void DrawString(const char* aString,
escapement_delta* delta = NULL);
void DrawString(const char* aString, BPoint location,
escapement_delta* delta = NULL);
void DrawString(const char* aString, int32 length,
escapement_delta* delta = NULL);
void DrawString(const char* aString,
int32 length,
BPoint location,
escapement_delta* delta = 0L);
virtual void SetFont(const BFont* font, uint32 mask = B_FONT_ALL);
#if !_PR3_COMPATIBLE_
void GetFont(BFont* font) const;
#else
void GetFont(BFont* font);
#endif
void TruncateString(BString* in_out,
uint32 mode,
float width) const;
float StringWidth(const char* string) const;
float StringWidth(const char* string, int32 length) const;
void GetStringWidths(char* stringArray[],
int32 lengthArray[],
int32 numStrings,
float widthArray[]) const;
void SetFontSize(float size);
void ForceFontAliasing(bool enable);
void GetFontHeight(font_height* height) const;
void Invalidate(BRect invalRect);
void Invalidate(const BRegion* invalRegion);
void Invalidate();
void SetDiskMode(char* filename, long offset);
void BeginPicture(BPicture* a_picture);
void AppendToPicture(BPicture* a_picture);
BPicture* EndPicture();
void DrawPicture(const BPicture* a_picture);
void DrawPicture(const BPicture* a_picture, BPoint where);
void DrawPicture(const char* filename, long offset, BPoint where);
void DrawPictureAsync(const BPicture* a_picture);
void DrawPictureAsync(const BPicture* a_picture, BPoint where);
void DrawPictureAsync(const char* filename, long offset,
BPoint where);
status_t SetEventMask(uint32 mask, uint32 options=0);
uint32 EventMask();
status_t SetMouseEventMask(uint32 mask, uint32 options=0);
virtual void SetFlags(uint32 flags);
uint32 Flags() const;
virtual void SetResizingMode(uint32 mode);
uint32 ResizingMode() const;
void MoveBy(float dh, float dv);
void MoveTo(BPoint where);
void MoveTo(float x, float y);
void ResizeBy(float dh, float dv);
void ResizeTo(float width, float height);
void ScrollBy(float dh, float dv);
void ScrollTo(float x, float y);
virtual void ScrollTo(BPoint where);
virtual void MakeFocus(bool focusState = true);
bool IsFocus() const;
virtual void Show();
virtual void Hide();
bool IsHidden() const;
bool IsHidden(const BView* looking_from) const;
void Flush() const;
void Sync() const;
virtual void GetPreferredSize(float* width, float* height);
virtual void ResizeToPreferred();
BScrollBar* ScrollBar(orientation posture) const;
virtual BHandler* ResolveSpecifier(BMessage* msg,
int32 index,
BMessage* specifier,
int32 form,
const char* property);
virtual status_t GetSupportedSuites(BMessage* data);
bool IsPrinting() const;
void SetScale(float scale) const;
// Private or reserved ---------------------------------------------------------
virtual status_t Perform(perform_code d, void* arg);
virtual void DrawAfterChildren(BRect r);
private:
friend class BScrollBar;
friend class BWindow;
friend class BBitmap;
friend class BPrintJob;
friend class BShelf;
friend class BTabView;
virtual void _ReservedView2();
virtual void _ReservedView3();
virtual void _ReservedView4();
virtual void _ReservedView5();
virtual void _ReservedView6();
virtual void _ReservedView7();
virtual void _ReservedView8();
#if !_PR3_COMPATIBLE_
virtual void _ReservedView9();
virtual void _ReservedView10();
virtual void _ReservedView11();
virtual void _ReservedView12();
virtual void _ReservedView13();
virtual void _ReservedView14();
virtual void _ReservedView15();
virtual void _ReservedView16();
#endif
BView(const BView&);
BView& operator=(const BView&);
void InitData(BRect f, const char* name, uint32 rs, uint32 fl);
status_t ArchiveChildren(BMessage* data, bool deep) const;
status_t UnarchiveChildren(BMessage* data, BWindow* w = NULL);
status_t SetViewImage(const BBitmap* bitmap,BRect srcRect, BRect dstRect,
uint32 followFlags, uint32 options);
void BeginPicture_pr(BPicture* a_picture, BRect r);
void SetPattern(pattern pat);
void DoBezier(int32 gr, BPoint* controlPoints, pattern p);
void DoShape(int32 gr, BShape* shape, pattern p);
void DoPictureClip(BPicture* picture, BPoint where, bool invert,
bool sync);
bool remove_from_list(BView* a_view);
bool remove_self();
bool do_owner_check() const;
void set_owner(BWindow* the_owner);
void do_activate(int32 state);
void check_lock() const;
void check_lock_no_pick() const;
void movesize(uint32 code, int32 h, int32 v);
void handle_tick();
char *test_area(int32 length);
void remove_comm_array();
_array_hdr_ *new_comm_array(int32 cnt);
BView *RealParent() const;
void SetScroller(BScrollBar* sb);
void UnsetScroller(BScrollBar* sb);
void RealScrollTo(BPoint);
void init_cache();
void set_cached_state();
void update_cached_state();
void set_font_state(const BFont* font, uint32 mask);
void fetch_font();
uchar font_encoding() const;
BShelf* shelf() const;
void set_shelf(BShelf* );
int32 server_token;
uint32 f_type;
float origin_h;
float origin_v;
BWindow* owner;
BView* parent;
BView* next_sibling;
BView* prev_sibling;
BView* first_child;
int16 fShowLevel;
bool top_level_view;
bool fNoISInteraction;
BPicture* cpicture;
_array_data_* comm;
BScrollBar* fVerScroller;
BScrollBar* fHorScroller;
bool f_is_printing;
bool attached;
bool _unused_bool1;
bool _unused_bool2;
_view_attr_* fPermanentState;
_view_attr_* fState;
BRect fCachedBounds;
BShelf* fShelf;
void* pr_state;
uint32 fEventMask;
uint32 fEventOptions;
uint32 _reserved[4];
#if !_PR3_COMPATIBLE_
uint32 _more_reserved[3];
#endif
};
//------------------------------------------------------------------------------
// inline definitions ----------------------------------------------------------
inline void BView::ScrollTo(float x, float y)
{
ScrollTo(BPoint(x, y));
}
//------------------------------------------------------------------------------
inline void BView::SetViewColor(uchar r, uchar g, uchar b, uchar a)
{
rgb_color a_color;
a_color.red = r; a_color.green = g;
a_color.blue = b; a_color.alpha = a;
SetViewColor(a_color);
}
//------------------------------------------------------------------------------
inline void BView::SetHighColor(uchar r, uchar g, uchar b, uchar a)
{
rgb_color a_color;
a_color.red = r; a_color.green = g;
a_color.blue = b; a_color.alpha = a;
SetHighColor(a_color);
}
//------------------------------------------------------------------------------
inline void BView::SetLowColor(uchar r, uchar g, uchar b, uchar a)
{
rgb_color a_color;
a_color.red = r; a_color.green = g;
a_color.blue = b; a_color.alpha = a;
SetLowColor(a_color);
}
//------------------------------------------------------------------------------
#endif // _VIEW_H
/*
* $Log $
*
* $Id $
*
*/
+456
View File
@@ -0,0 +1,456 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Window.h
// Author: Erik Jaesler ([email protected])
// Description: BWindow is the base class for all windows (graphic areas
// displayed on-screen).
//------------------------------------------------------------------------------
#ifndef _WINDOW_H
#define _WINDOW_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <InterfaceDefs.h>
#include <List.h>
#include <Looper.h>
#include <Rect.h>
#include <StorageDefs.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
// window definitions ----------------------------------------------------------
enum window_type {
B_UNTYPED_WINDOW = 0,
B_TITLED_WINDOW = 1,
B_MODAL_WINDOW = 3,
B_DOCUMENT_WINDOW = 11,
B_BORDERED_WINDOW = 20,
B_FLOATING_WINDOW = 21
};
//----------------------------------------------------------------
enum window_look {
B_BORDERED_WINDOW_LOOK = 20,
B_NO_BORDER_WINDOW_LOOK = 19,
B_TITLED_WINDOW_LOOK = 1,
B_DOCUMENT_WINDOW_LOOK = 11,
B_MODAL_WINDOW_LOOK = 3,
B_FLOATING_WINDOW_LOOK = 7
};
//----------------------------------------------------------------
enum window_feel {
B_NORMAL_WINDOW_FEEL = 0,
B_MODAL_SUBSET_WINDOW_FEEL = 2,
B_MODAL_APP_WINDOW_FEEL = 1,
B_MODAL_ALL_WINDOW_FEEL = 3,
B_FLOATING_SUBSET_WINDOW_FEEL = 5,
B_FLOATING_APP_WINDOW_FEEL = 4,
B_FLOATING_ALL_WINDOW_FEEL = 6
};
//----------------------------------------------------------------
enum window_alignment {
B_BYTE_ALIGNMENT = 0,
B_PIXEL_ALIGNMENT = 1
};
//----------------------------------------------------------------
enum {
B_NOT_MOVABLE = 0x00000001,
B_NOT_CLOSABLE = 0x00000020,
B_NOT_ZOOMABLE = 0x00000040,
B_NOT_MINIMIZABLE = 0x00004000,
B_NOT_RESIZABLE = 0x00000002,
B_NOT_H_RESIZABLE = 0x00000004,
B_NOT_V_RESIZABLE = 0x00000008,
B_AVOID_FRONT = 0x00000080,
B_AVOID_FOCUS = 0x00002000,
B_WILL_ACCEPT_FIRST_CLICK = 0x00000010,
B_OUTLINE_RESIZE = 0x00001000,
B_NO_WORKSPACE_ACTIVATION = 0x00000100,
B_NOT_ANCHORED_ON_ACTIVATE = 0x00020000,
B_ASYNCHRONOUS_CONTROLS = 0x00080000,
B_QUIT_ON_WINDOW_CLOSE = 0x00100000
};
#define B_CURRENT_WORKSPACE 0
#define B_ALL_WORKSPACES 0xffffffff
//----------------------------------------------------------------
class _BSession_;
class BButton;
class BMenuBar;
class BMenuItem;
class BMessage;
class BMessageRunner;
class BMessenger;
class BView;
struct message;
struct _cmd_key_;
struct _view_attr_;
// BWindow class ---------------------------------------------------------------
class BWindow : public BLooper {
public:
BWindow(BRect frame,
const char* title,
window_type type,
uint32 flags,
uint32 workspace = B_CURRENT_WORKSPACE);
BWindow(BRect frame,
const char* title,
window_look look,
window_feel feel,
uint32 flags,
uint32 workspace = B_CURRENT_WORKSPACE);
virtual ~BWindow();
BWindow(BMessage* data);
static BArchivable *Instantiate(BMessage* data);
virtual status_t Archive(BMessage* data, bool deep = true) const;
virtual void Quit();
void Close(); // Synonym of Quit()
void AddChild(BView* child, BView* before = NULL);
bool RemoveChild(BView* child);
int32 CountChildren() const;
BView *ChildAt(int32 index) const;
virtual void DispatchMessage(BMessage* message, BHandler* handler);
virtual void MessageReceived(BMessage* message);
virtual void FrameMoved(BPoint new_position);
virtual void WorkspacesChanged(uint32 old_ws, uint32 new_ws);
virtual void WorkspaceActivated(int32 ws, bool state);
virtual void FrameResized(float new_width, float new_height);
virtual void Minimize(bool minimize);
virtual void Zoom( BPoint rec_position,
float rec_width,
float rec_height);
void Zoom();
void SetZoomLimits(float max_h, float max_v);
virtual void ScreenChanged(BRect screen_size, color_space depth);
void SetPulseRate(bigtime_t rate);
bigtime_t PulseRate() const;
void AddShortcut( uint32 key,
uint32 modifiers,
BMessage* msg);
void AddShortcut( uint32 key,
uint32 modifiers,
BMessage* msg,
BHandler* target);
void RemoveShortcut(uint32 key, uint32 modifiers);
void SetDefaultButton(BButton* button);
BButton *DefaultButton() const;
virtual void MenusBeginning();
virtual void MenusEnded();
bool NeedsUpdate() const;
void UpdateIfNeeded();
BView *FindView(const char* view_name) const;
BView *FindView(BPoint) const;
BView *CurrentFocus() const;
void Activate(bool = true);
virtual void WindowActivated(bool state);
void ConvertToScreen(BPoint* pt) const;
BPoint ConvertToScreen(BPoint pt) const;
void ConvertFromScreen(BPoint* pt) const;
BPoint ConvertFromScreen(BPoint pt) const;
void ConvertToScreen(BRect* rect) const;
BRect ConvertToScreen(BRect rect) const;
void ConvertFromScreen(BRect* rect) const;
BRect ConvertFromScreen(BRect rect) const;
void MoveBy(float dx, float dy);
void MoveTo(BPoint);
void MoveTo(float x, float y);
void ResizeBy(float dx, float dy);
void ResizeTo(float width, float height);
virtual void Show();
virtual void Hide();
bool IsHidden() const;
bool IsMinimized() const;
void Flush() const;
void Sync() const;
status_t SendBehind(const BWindow* window);
void DisableUpdates();
void EnableUpdates();
void BeginViewTransaction();
void EndViewTransaction();
BRect Bounds() const;
BRect Frame() const;
const char *Title() const;
void SetTitle(const char* title);
bool IsFront() const;
bool IsActive() const;
void SetKeyMenuBar(BMenuBar* bar);
BMenuBar *KeyMenuBar() const;
void SetSizeLimits( float min_h,
float max_h,
float min_v,
float max_v);
void GetSizeLimits( float* min_h,
float* max_h,
float* min_v,
float* max_v);
uint32 Workspaces() const;
void SetWorkspaces(uint32);
BView *LastMouseMovedView() const;
virtual BHandler *ResolveSpecifier(BMessage* msg,
int32 index,
BMessage* specifier,
int32 form,
const char* property);
virtual status_t GetSupportedSuites(BMessage* data);
status_t AddToSubset(BWindow* window);
status_t RemoveFromSubset(BWindow* window);
virtual status_t Perform(perform_code d, void* arg);
status_t SetType(window_type type);
window_type Type() const;
status_t SetLook(window_look look);
window_look Look() const;
status_t SetFeel(window_feel feel);
window_feel Feel() const;
status_t SetFlags(uint32);
uint32 Flags() const;
bool IsModal() const;
bool IsFloating() const;
status_t SetWindowAlignment(window_alignment mode,
int32 h,
int32 hOffset = 0,
int32 width = 0,
int32 widthOffset = 0,
int32 v = 0,
int32 vOffset = 0,
int32 height = 0,
int32 heightOffset = 0);
status_t GetWindowAlignment(window_alignment* mode = NULL,
int32* h = NULL,
int32* hOffset = NULL,
int32* width = NULL,
int32* widthOffset = NULL,
int32* v = NULL,
int32* vOffset = NULL,
int32* height = NULL,
int32* heightOffset = NULL) const;
virtual bool QuitRequested();
virtual thread_id Run();
// Private or reserved ---------------------------------------------------------
private:
typedef BLooper inherited;
friend class BApplication;
friend class BBitmap;
friend class BScrollBar;
friend class BView;
friend class BMenuItem;
friend class BWindowScreen;
friend class BDirectWindow;
friend class BFilePanel;
friend class _CEventPort_;
friend void _set_menu_sem_(BWindow* w, sem_id sem);
friend status_t _safe_get_server_token_(const BLooper* , int32* );
virtual void _ReservedWindow1();
virtual void _ReservedWindow2();
virtual void _ReservedWindow3();
virtual void _ReservedWindow4();
virtual void _ReservedWindow5();
virtual void _ReservedWindow6();
virtual void _ReservedWindow7();
virtual void _ReservedWindow8();
BWindow();
BWindow(BWindow&);
BWindow &operator=(BWindow&);
BWindow(BRect frame, color_space depth,
uint32 bitmapFlags, int32 rowBytes);
void InitData(BRect frame,
const char* title,
window_look look,
window_feel feel,
uint32 flags,
uint32 workspace);
status_t ArchiveChildren(BMessage* data, bool deep) const;
status_t UnarchiveChildren(BMessage* data);
void BitmapClose();
virtual void task_looper();
void start_drag( BMessage* msg,
int32 token,
BPoint offset,
BRect track_rect,
BHandler* reply_to);
void start_drag( BMessage* msg,
int32 token,
BPoint offset,
int32 bitmap_token,
drawing_mode dragMode,
BHandler* reply_to);
void view_builder(BView* a_view);
void attach_builder(BView* a_view);
void detach_builder(BView* a_view);
int32 get_server_token() const;
BMessage *extract_drop(BMessage* an_event, BHandler* *target);
void movesize(uint32 opcode, float h, float v);
BMessage* ReadMessageFromPort(bigtime_t tout = B_INFINITE_TIMEOUT);
int32 MessagesWaiting();
void handle_activate(BMessage* an_event);
void do_view_frame(BMessage* an_event);
void do_value_change(BMessage* an_event, BHandler* handler);
void do_mouse_down(BMessage* an_event, BView* target);
void do_mouse_moved(BMessage* an_event, BView* target);
void do_key_down(BMessage* an_event, BHandler* handler);
void do_key_up(BMessage* an_event, BHandler* handler);
void do_menu_event(BMessage* an_event);
void do_draw_views();
virtual BMessage *ConvertToMessage(void* raw, int32 code);
_cmd_key_ *allocShortcut(uint32 key, uint32 modifiers);
_cmd_key_ *FindShortcut(uint32 key, uint32 modifiers);
void AddShortcut(uint32 key,
uint32 modifiers,
BMenuItem* item);
void post_message(BMessage* message);
void SetLocalTitle(const char* new_title);
void enable_pulsing(bool enable);
BHandler *determine_target(BMessage* msg, BHandler* target, bool pref);
void kb_navigate();
void navigate_to_next(int32 direction, bool group = false);
void set_focus(BView* focus, bool notify_input_server);
bool InUpdate();
void DequeueAll();
bool find_token_and_handler(BMessage* msg,
int32* token,
BHandler* *handler);
window_type compose_type(window_look look,
window_feel feel) const;
void decompose_type(window_type type,
window_look* look,
window_feel* feel) const;
void SetIsFilePanel(bool panel);
bool IsFilePanel() const;
// 3 deprecated calls
void AddFloater(BWindow* a_floating_window);
void RemoveFloater(BWindow* a_floating_window);
window_type WindowType() const;
char *fTitle;
int32 server_token;
char fInUpdate;
char f_active;
short fShowLevel;
uint32 fFlags;
port_id send_port;
port_id receive_port;
BView *top_view;
BView *fFocus;
BView *fLastMouseMovedView;
_BSession_ *a_session;
BMenuBar *fKeyMenuBar;
BButton *fDefaultButton;
BList accelList;
int32 top_view_token;
bool pulse_enabled;
bool fViewsNeedPulse;
bool fIsFilePanel;
bool fUnused1;
bigtime_t pulse_rate;
bool fWaitingForMenu;
bool fOffscreen;
sem_id fMenuSem;
float fMaxZoomH;
float fMaxZoomV;
float fMinWindH;
float fMinWindV;
float fMaxWindH;
float fMaxWindV;
BRect fFrame;
window_look fLook;
_view_attr_ *fCurDrawViewState;
window_feel fFeel;
int32 fLastViewToken;
_CEventPort_* fEventPort;
BMessageRunner *fPulseRunner;
BRect fCurrentFrame;
uint32 _reserved[2]; // was 8
#if !_PR3_COMPATIBLE_
uint32 _more_reserved[4];
#endif
};
// inline definitions ----------------------------------------------------------
inline void BWindow::Close()
{
Quit();
}
//------------------------------------------------------------------------------
#endif // _WINDOW_H
/*
* $Log $
*
* $Id $
*
*/
+246
View File
@@ -0,0 +1,246 @@
/* OS.h
*
* Quake with fear - it's back!!!
*/
#ifndef _OS_H
#define _OS_H
/**
* @mainpage OpenBeOS Header Documentation
*
* @section Introduction
* This is the header documentation as produced with doxygen. Anyone can
* produce this using the doxygen tool and doing this
* <pre>
* cd docs
* doxygen doxygen.conf
* </pre>
* The resulting files will be produced in dox/html.
*
* @section Updating
* I will attempt to keep these up to date, but if they're not, just
* give me a nudge!
*/
/**
* @file kernel/OS.h
* @brief Definitions, prototypes needed throughout the OS
*/
/**
* @defgroup OpenBeOS_Headers OpenBeOS System Headers
* @brief Headers that are available for applications
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <ktypes.h>
#define B_OS_NAME_LENGTH 32
/**
* @defgroup Areas Memory Areas
* @ingroup OpenBeOS_Headers
* @{
*/
/* temporary hacks */
typedef int32 team_id;
typedef int32 area_id;
/* Areas */
typedef struct area_info {
area_id area;
char name[B_OS_NAME_LENGTH];
int foo;
size_t size;
uint32 lock;
uint32 protection;
team_id team;
uint32 ram_size;
uint32 copy_count;
uint32 in_count;
uint32 out_count;
void *address;
} area_info;
#define get_area_info(id, ainfo) \
_get_area_info((id), (ainfo),sizeof(*(ainfo)))
#define get_next_area_info(team, cookie, ainfo) \
_get_next_area_info((team), (cookie), (ainfo), sizeof(*(ainfo)))
/** @} */
/**
* @defgroup Ports Messaging Ports
* @ingroup OpenBeOS_Headers
* @{
*/
/* Ports */
typedef struct port_info {
port_id port;
team_id team;
char name[B_OS_NAME_LENGTH];
int32 capacity; /* queue depth */
int32 queue_count; /* # msgs waiting to be read */
int32 total_count; /* total # msgs read so far */
} port_info;
port_id create_port(int32, const char *);
port_id find_port(const char *);
int read_port(port_id, int32 *, void *, size_t);
int read_port_etc(port_id, int32 *, void *, size_t, uint32, bigtime_t);
int write_port(port_id, int32, const void *, size_t);
int write_port_etc(port_id, int32, const void *, size_t, uint32, bigtime_t);
int close_port(port_id port);
int delete_port(port_id port);
ssize_t port_buffer_size(port_id);
ssize_t port_buffer_size_etc(port_id, uint32, bigtime_t);
ssize_t port_count(port_id);
int set_port_owner(port_id, team_id);
int _get_port_info(port_id, port_info *, size_t);
int _get_next_port_info(team_id, int32 *, port_info *, size_t);
#define get_port_info(port, info) \
_get_port_info((port), (info), sizeof(*(info)))
#define get_next_port_info(team, cookie, info) \
_get_next_port_info((team), (cookie), (info), sizeof(*(info)))
/** @} */
/**
* @defgroup Sems Semaphores
* @ingroup OpenBeOS_Headers
* @{
*/
#define B_CAN_INTERRUPT 1
#define B_DO_NOT_RESCHEDULE 2
#define B_CHECK_PERMISSION 4
#define B_TIMEOUT 8
#define B_RELATIVE_TIMEOUT 8
#define B_ABSOLUTE_TIMEOUT 16
typedef struct sem_info {
sem_id sem;
proc_id proc;
char name[B_OS_NAME_LENGTH];
int32 count;
thread_id latest_holder;
} sem_info;
sem_id create_sem_etc(int count, const char *name, proc_id owner);
sem_id create_sem(int count, const char *name);
int delete_sem(sem_id id);
int delete_sem_etc(sem_id id, int return_code);
int acquire_sem(sem_id id);
int acquire_sem_etc(sem_id id, int count, int flags, bigtime_t timeout);
int release_sem(sem_id id);
int release_sem_etc(sem_id id, int count, int flags);
int get_sem_count(sem_id id, int32* thread_count);
int _get_sem_info(sem_id id, struct sem_info *info, size_t);
int _get_next_sem_info(proc_id proc, uint32 *cookie, struct sem_info *info, size_t);
int set_sem_owner(sem_id id, proc_id proc);
#define get_sem_info(sem, info) \
_get_sem_info((sem), (info), sizeof(*(info)))
#define get_next_sem_info(team, cookie, info) \
_get_next_sem_info((team), (cookie), (info), sizeof(*(info)))
/** @} */
/**
* @defgroup Threads Threads
* @ingroup OpenBeOS_Headers
* @{
*/
/* Threads */
//enum {
// THREAD_STATE_READY = 0, // ready to run
// THREAD_STATE_RUNNING, // running right now somewhere
// THREAD_STATE_WAITING, // blocked on something
// THREAD_STATE_SUSPENDED, // suspended, not in queue
// THREAD_STATE_FREE_ON_RESCHED, // free the thread structure upon reschedule
// THREAD_STATE_BIRTH // thread is being created
//};
typedef enum {
B_THREAD_RUNNING=1,
B_THREAD_READY,
B_THREAD_RECEIVING,
B_THREAD_ASLEEP,
B_THREAD_SUSPENDED,
B_THREAD_WAITING
} thread_state;
#define THREAD_IDLE_PRIORITY 0
#define THREAD_NUM_PRIORITY_LEVELS 64
#define THREAD_MIN_PRIORITY (THREAD_IDLE_PRIORITY + 1)
#define THREAD_MAX_PRIORITY (THREAD_NUM_PRIORITY_LEVELS - THREAD_NUM_RT_PRIORITY_LEVELS - 1)
#define THREAD_NUM_RT_PRIORITY_LEVELS 16
#define THREAD_MIN_RT_PRIORITY (THREAD_MAX_PRIORITY + 1)
#define THREAD_MAX_RT_PRIORITY (THREAD_NUM_PRIORITY_LEVELS - 1)
#define THREAD_LOWEST_PRIORITY THREAD_MIN_PRIORITY
#define THREAD_LOW_PRIORITY 12
#define THREAD_MEDIUM_PRIORITY 24
#define THREAD_HIGH_PRIORITY 36
#define THREAD_HIGHEST_PRIORITY THREAD_MAX_PRIORITY
#define THREAD_RT_LOW_PRIORITY THREAD_MIN_RT_PRIORITY
#define THREAD_RT_HIGH_PRIORITY THREAD_MAX_RT_PRIORITY
#define B_LOW_PRIORITY 5
#define B_NORMAL_PRIORITY 10
#define B_DISPLAY_PRIORITY 15
#define B_URGENT_DISPLAY_PRIORITY 20
#define B_REAL_TIME_DISPLAY_PRIORITY 100
#define B_URGENT_PRIORITY 110
#define B_REAL_TIME_PRIORITY 120
typedef struct {
thread_id thread;
team_id team;
char name[B_OS_NAME_LENGTH];
thread_state state;
int32 priority;
sem_id sem;
bigtime_t user_time;
bigtime_t kernel_time;
void *stack_base;
void *stack_end;
} thread_info;
typedef struct {
bigtime_t user_time;
bigtime_t kernel_time;
} team_usage_info;
typedef int32 (*thread_func) (void *);
thread_id spawn_thread (thread_func, const char *, int32, void *);
int kill_thread(thread_id thread);
int resume_thread(thread_id thread);
int suspend_thread(thread_id thread);
thread_id find_thread(const char *);
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* _OS_H */
+35
View File
@@ -0,0 +1,35 @@
/**
* @file dirent.h
* @brief File Control functions and definitions
*/
#ifndef _DIRENT_H
#define _DIRENT_H
typedef struct dirent {
vnode_id d_ino;
unsigned short d_reclen;
char d_name[1];
} dirent_t;
typedef struct {
int fd;
struct dirent *ent;
struct dirent me;
} DIR;
#ifndef MAXNAMLEN
#ifdef NAME_MAX
#define MAXNAMLEN NAME_MAX
#else
#define MAXNAMLEN 256
#endif
#endif
DIR *opendir(const char *dirname);
struct dirent *readdir(DIR *dirp);
int closedir(DIR *dirp);
void rewinddir(DIR *dirp);
#endif /* _DIRENT_H */
+341
View File
@@ -0,0 +1,341 @@
/*-
* Copyright (c) 1983, 1990, 1993
* The Regents of the University of California. All rights reserved.
* (c) UNIX System Laboratories, Inc.
* All or some portions of this file are derived from material licensed
* to the University of California by American Telephone and Telegraph
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
* the permission of UNIX System Laboratories, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)fcntl.h 8.3 (Berkeley) 1/21/94
*/
/**
* @file fcntl.h
* @brief File Control functions and definitions
*/
#ifndef _FCNTL_H_
#define _FCNTL_H_
/**
* @defgroup Fcntl fcntl.h
* @brief File Control functions and definitions
* @note Definitions in this file also apply to open() and
* internally in the kernel
* @note Relevant kernel functions should be here as well
* @ingroup OpenBeOS_POSIX
* @{
*/
#ifndef _KERNEL_
//#include <sys/types.h>
#endif
/**
* @defgroup File_Status_Flags File Status Flags
* The flags described in this section are used by fcntl(), open() and also
* withing the kernel.
* @note O_ are used by fcntl() and open()
* @note F flags are used by the kernel
* @ingroup fcntl
* @{
*/
/** open for reading only */
#define O_RDONLY 0x0000
/** open for writing only */
#define O_WRONLY 0x0001
/** open for reading and writing */
#define O_RDWR 0x0002
/** mask for above modes */
#define O_ACCMODE 0x0003
#ifndef _POSIX_SOURCE
/** kernel flag to allow testing of read/write directly
* @note not #ifdef _KERNEL_ to allow TIOCFLUSH to work */
#define FREAD 0x0001
/** kernel flag to allow testing of read/write directly
* @note not #ifdef _KERNEL_ to allow TIOCFLUSH to work */
#define FWRITE 0x0002
#endif
/** no delay */
#define O_NONBLOCK 0x0004
/** set append mode */
#define O_APPEND 0x0008
/** open with shared file lock */
#define O_SHLOCK 0x0010
/** open with exclusive file lock */
#define O_EXLOCK 0x0020
/** signal pgrp when data ready */
#define O_ASYNC 0x0040
/** backwards compatibility */
#define O_FSYNC O_SYNC
/** if path is a symlink, don't follow */
#define O_NOFOLLOW 0x0100
/** synchronous writes */
#define O_SYNC 0x0080
/** create if nonexistant */
#define O_CREAT 0x0200
/** truncate to zero length */
#define O_TRUNC 0x0400
/** error if already exists */
#define O_EXCL 0x0800
#ifdef _KERNEL_
/* mark during gc() */
#define FMARK 0x1000
/* defer for next gc pass */
#define FDEFER 0x2000
/* descriptor holds advisory lock */
#define FHASLOCK 0x4000
#endif
/*
* POSIX 1003.1 specifies a higher granularity for syncronous operations
* than are currently supported. We may want to look at what needs to be done
* to support these. At present just map them.
*/
/** @def O_DSYNC synchronous data writes */
#define O_DSYNC O_SYNC
/** @def O_RSYNC synchronous reads */
#define O_RSYNC O_SYNC
/* defined by POSIX 1003.1; BSD default, this bit is not required */
/** @def O_NOCTTY don't assign controlling terminal */
#define O_NOCTTY 0x8000
#ifdef _KERNEL_
/*
* convert from open() flags to/from fflags; convert O_RD/WR to FREAD/FWRITE.
* For out-of-range values for the flags, be slightly careful (but lossy).
*/
/** @def FFLAGS(oflags) Convert from O_ flags to F flags for kernel */
#define FFLAGS(oflags) (((oflags) & ~O_ACCMODE) | (((oflags) + 1) & O_ACCMODE))
/** @def OFLAGS(fflags) Convert from F flags to O_ flags for open() */
#define OFLAGS(fflags) (((fflags) & ~O_ACCMODE) | (((fflags) - 1) & O_ACCMODE))
/** @def FMASK bits to save after open */
#define FMASK (FREAD|FWRITE|FAPPEND|FASYNC|FFSYNC|FNONBLOCK)
/** @def FCNTLFLAGS bits settable by fcntl(F_SETFL, ...) */
#define FCNTLFLAGS (FAPPEND|FASYNC|FFSYNC|FNONBLOCK)
#endif
/*
* The O_* flags used to have only F* names, which were used in the kernel
* and by fcntl. We retain the F* names for the kernel f_flags field
* and for backward compatibility for fcntl.
*/
#ifndef _POSIX_SOURCE
/** kernel/compat */
#define FAPPEND O_APPEND
/** kernel/compat */
#define FASYNC O_ASYNC
/** kernel */
#define FFSYNC O_SYNC
/** kernel */
#define FNONBLOCK O_NONBLOCK
/** compat */
#define FNDELAY O_NONBLOCK
/** compat */
#define O_NDELAY O_NONBLOCK
#endif
/** @} */
/**
* @defgroup FCNTL_Flags Flags used for fcntl()
* @ingroup FCNTL
* @{
*/
/**
* @def F_DUPFD Return a new file descriptor that has
* @li the lowest number available (>= fd used)
* @li same object references as original fd
* @li same offsets as original (file only)
* @li same file status
* @li close-on-exec flag is set so it will remain open across execv()
*
* @ref FD_CLOEXEC
*/
#define F_DUPFD 0 /* duplicate file descriptor */
/** @def F_GETFD Get the close-on-exec flag for the fd
* @note the argument is ignored
* @ref FD_CLOEXEC */
#define F_GETFD 1
/** @def F_SETFD Set the close-on-exec flag for the fd
* @ref FD_CLOEXEC */
#define F_SETFD 2
/** @def F_GETFL Get fd status flags */
#define F_GETFL 3
/** @def F_SETFL Set the fd status flags */
#define F_SETFL 4
/** @def F_GETOWN Get the process ID receiving SIGIO/SIGURG signals */
#define F_GETOWN 5
/** @def F_SETOWN Set the process ID receiving SIGIO/SIGURG signals */
#define F_SETOWN 6
/** @def F_GETLK Get the first lock that blocks the requested lock requested
* int the flock structure passed in.
* @li If the call succeeds then the structure is returned unaltered except
* the lock type is set to F_UNLCK
* @li If the call fails the details of the blocking lock will be inserted
* into the strcture, overwriting the details submitted.
*/
#define F_GETLK 7
/** @def F_SETLK Set/Clear a file segment lock based on the flock structure
* passed in.
* @note If a shared/exclusive lock cannot be set, EAGAIN will be returned
*/
#define F_SETLK 8
/** @def F_SETLKW Same as F_SETLK but will block if a shared/exclusive
* lock is requested and is not available.
*/
#define F_SETLKW 9
/* file descriptor flags (F_GETFD, F_SETFD) */
/** @def FD_CLOEXEC Flag set in status is fd is set to remain open
* across exec
* @ref F_DUPFD
* @ref F_GETFD
* @ref F_SETFD
*/
#define FD_CLOEXEC 1 /* close-on-exec flag */
/** @} */
/**
* @defgroup FCNTL_FileLocks Locking types for fcntl()
* @ingroup FCNTL
* @{
*/
/** shared or read lock */
#define F_RDLCK 1
/** unlock */
#define F_UNLCK 2
/** exclusive or write lock */
#define F_WRLCK 3
#ifdef _KERNEL_
/** Wait until lock is granted */
#define F_WAIT 0x010
/** Use flock(2) semantics for lock */
#define F_FLOCK 0x020
/** Use POSIX semantics for lock */
#define F_POSIX 0x040
#endif
/** @} */
/**
* Advisory file segment locking data type -
* information passed to system by user
* @note This structure can be used to lock all or part of a file
* @note Not yet implemented in OpenBeOS
*/
struct flock {
/** starting offset for lock */
off_t l_start;
/** length of lock required (0 means lock to end of file) */
off_t l_len;
/** process id of process owning lock */
pid_t l_pid;
/** type of lock
* @link FCNTL_FileLocks */
short l_type;
/** type of start poition given */
short l_whence;
};
/**
* @defgroup FCNTL_flock Locking types for flock()
* @ingroup FCNTL
* @{
*/
/** shared lock */
#define LOCK_SH 0x01
/** exclusive lock */
#define LOCK_EX 0x02
/** don't block when locking */
#define LOCK_NB 0x04
/** unlock */
#define LOCK_UN 0x08
/** @} */
#ifndef _KERNEL_MODE
//#include <sys/cdefs.h>
#include <ktypes.h>
/** @fn int open(const char *path, int oflags, ...);
* Used to open or create a file for reading/writing
* @note oflags passed should be OR'd together, e.g.
* @code
* int fd = open("file.txt", O_RDWR | O_APPEND | O_CREAT);
* @endcode
* @note if the flag O_CREAT is supplied and the file given by path doesn't
* exist it will be created.
*
* @ref File_Status_Flags
*/
int open (const char *, int, ...);
/** @fn int creat(const char *path, mode_t mode)
* Creates a file.
* @note Obsoleted by open()
* @code
* Same as doing open(path, O_CREAT | O_TRUNC | O_WRONLY, mode);
* @endcode
* @ref open()
*/
int creat (const char *, mode_t);
/** @fn int fcntl(int fd, int cmd, ...)
* Provides control over the properties of a descriptor that is
* already open. The 3rd paramater is technically a void *, but may
* be interpretted as an int by some commands or cast by others.
* @ref FCNTL_Flags should be used as the cmd parameter
*/
int fcntl (int, int, ...);
/** @fn int flock(int fd, int operation)
* Applies or removes an advisory lock from descriptor fd.
* @ref FCNTL_flock codes should be used as the operation parameter
*/
int flock (int, int);
#endif
/** @} */
#endif /* !_SYS_FCNTL_H_ */
+26
View File
@@ -0,0 +1,26 @@
/* domain.h */
/* A domain is just a container for like minded protocols! */
#ifndef DOMAIN_H
#define DOMAIN_H
struct domain {
int dom_family; /* AF_INET and so on */
char *dom_name;
void (*dom_init)(void); /* initialise */
struct protosw *dom_protosw; /* the protocols we have */
struct domain *dom_next;
int (*dom_rtattach)(void **, int);
int dom_rtoffset;
int dom_maxrtkey;
};
struct domain *domains;
void add_domain(struct domain *dom, int fam);
void remove_domain(int fam);
#endif /* DOMAIN_H */
+40
View File
@@ -0,0 +1,40 @@
/**
* @file sys/filio.h
* @brief ioctl() definitions for file descriptor operations
*/
#ifndef _SYS_FILIO_H
#define _SYS_FILIO_H
/**
* @defgroup IOCTL_filio sys/filio.h
* @brief ioctl() definitions for file descriptor operations
* @ingroup OpenBeOS_POSIX
* @ingroup IOCTL
* @{
*/
#include <sys/ioccom.h>
/** @def FIOCLEX set close on exec
* @ref FD_CLOEXEC */
#define FIOCLEX _IO('f', 1)
/** @def FIONCLEX remove close on exec flag
* @ref FD_CLOEXEC*/
#define FIONCLEX _IO('f', 2)
/** @def FIBMAP get logical block
* @note this is not yet implemented on OpenBeOS */
#define FIBMAP _IOWR('f', 122, void *)
/** @def FIOASYNC set/clear async I/O */
#define FIOASYNC _IOW('f', 123, int)
/** @def FIOGETOWN get owner */
#define FIOGETOWN _IOR('f', 123, int)
/** @def FIOSETOWN set owner */
#define FIOSETOWN _IOW('f', 123, int)
/** @def FIONBIO set/clear non-blocking I/O */
#define FIONBIO _IOW('f', 126, int)
/** @def FIONREAD get number of bytes available to read */
#define FIONREAD _IOW('f', 127, int)
/** @} */
#endif /* _SYS_FILIO_H */
+80
View File
@@ -0,0 +1,80 @@
/**
* @file sys/ioccom.h
* @brief Definitions & maros common to ioctl
*/
#ifndef _SYS_IOCCOM_H
#define _SYS_IOCCOM_H
/**
* @defgroup IOCTL_common sys/ioccom.h
* @brief Definitions & maros common to ioctl()
* @ingroup OpenBeOS_POSIX
* @ingroup IOCTL
* Ioctl values passed as the command (2nd) variable have the
* command encoded in the lower word and the size of any parameters
* in the upper word (in or out).
* The high 3 bits are used to encode whether it's in or out.
* Due to this you can't just give an ioctl value, you need to encode
* it using macros described in
* @ref IOCTL_macros
* @{
*/
/** @defgroup IOCTL_parm ioctl() parameter definitions
* @ingroup IOCTL_common
* @{
*/
/** @def IOC_VOID */
#define IOC_VOID (ulong)0x20000000
/** @def IOC_OUT ioctl expects data (output) */
#define IOC_OUT (ulong)0x40000000
/** @def IOC_IN ioctl passes a value in */
#define IOC_IN (ulong)0x80000000
/** @def IOC_INOUT ioctl passes data in and out */
#define IOC_INOUT (IOC_IN|IOC_OUT)
/** @def IOC_DIRMASK */
#define IOC_DIRMASK (ulong)0xe0000000
/** @} */
/**
* @defgroup IOCTL_macros IOCTL macros
* These should be used to define the values passed in as cmd to
* ioctl()
* @ingroup IOCTL_common
* @{
*/
/** @def IOCPARM_MASK mask used to for following macros */
#define IOCPARM_MASK 0x1fff
/** @def IOCPARM_LEN(x) length of the data passed as param */
#define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK)
/** @def IOCBASECMD(x) the base command encoded in the ioctl value */
#define IOCBASECMD(x) ((x) & ~(IOCPARM_MASK << 16))
/** @def IOCGROUP(x) which group of ioctl() commands does this belong to? */
#define IOCGROUP(x) (((x) >> 8) & 0xff)
/** @def IOCPARM_MAX Maximum size of parameter that can be passed (20 bytes) */
#define IOCPARM_MAX 20
/**
* @defgroup IOCTL_createmacros macro's to create ioctl() values
* @brief these macro's should be used to create new ioctl() values
* @ingroup IOCTL_common
* @{
*/
/** @def _IOC(inout, group, num , len) create a new ioctl */
#define _IOC(inout, group, num, len) \
(inout | ((len & IOCPARM_MASK)<<16) | ((group) << 8) | (num))
/** @def _IO(g,n) create a new void ioctl for group g, number n */
#define _IO(g,n) _IOC(IOC_VOID, (g), (n), 0)
/** @def _IOR(g,n,t) create a ioctl() that reads a value of type t*/
#define _IOR(g,n,t) _IOC(IOC_OUT, (g), (n), sizeof(t))
/** @def _IOW(g,n,t) ioctl() that writes value of type t, group g, number n */
#define _IOW(g,n,t) _IOC(IOC_IN , (g), (n), sizeof(t))
/** @def _IOWR(g,n,t) ioctl() that reads/writes value of type t
* @note this isn't _IORW as this causes name conflicts on some systems */
#define _IOWR(g,n,t) _IOC(IOC_INOUT, (g), (n), sizeof(t))
/** @} */
/** @} */
#endif /* _SYS_IOCCOM_H */
+37
View File
@@ -0,0 +1,37 @@
/**
* @file sys/ioctl.h
* @brief I/O control functions
*/
#ifndef _SYS_IOCTL_H
#define _SYS_IOCTL_H
/**
* @defgroup IOCTL sys/ioctl.h
* @brief I/O control functions
* @ingroup OpenBeOS_POSIX
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/ioccom.h>
#include <sys/filio.h>
#include <sys/socket.h>
#ifndef _KERNEL_MODE
/** @fn int ioctl(int fd, ulong cmd, ...)
* Manipulates the characteristics of the affected descriptor. May be used
* on all forms of descriptor, including sockets and pipes. cmd should be one
* of the values given in
* @ref IOCTL_cmds
*/
int ioctl(int, ulong, ...);
#endif /* !_KERNEL_MODE */
/** @} */
#endif /* _SYS_IOCTL_H */
+147
View File
@@ -0,0 +1,147 @@
/* protosw.h */
#ifndef PROTOSW_H
#define PROTOSW_H
#include "sys/socketvar.h" /* for struct socket */
#include "net/route.h"
#define PRCO_SETOPT 0
#define PRCO_GETOPT 1
/* every protocol module init's one of these and passes it into
* the add_protocol() function, defined below */
/* NB The pr_domain pointer will be filled in during the
* add_protocol() call
*/
struct protosw {
char *name;
char *mod_path;
uint16 pr_type; /* SOCK_xxx */
struct domain *pr_domain;
uint16 pr_protocol; /* protocol number */
uint16 pr_flags; /* flags, PR_xxx */
int layer; /* which layer are we? */
/* the functions! */
void (*pr_init)(void);
void (*pr_input)(struct mbuf*, int);
int (*pr_output)(struct mbuf *, struct mbuf *,
struct route *,
int, void *);
int (*pr_userreq)(struct socket *, int,
struct mbuf *,
struct mbuf *,
struct mbuf *);
int (*pr_sysctl)(int *, uint, void *, size_t *, void *, size_t);
void (*pr_ctlinput)(int, struct sockaddr *, void *);
int (*pr_ctloutput)(int, struct socket*, int, int, struct mbuf **);
struct protosw *pr_next; /* pointer to next proto structure */
struct protosw *dom_next; /* next protosw pointed by the domain */
};
/*
* Values for pr_flags.
* PR_ADDR requires PR_ATOMIC;
* PR_ADDR and PR_CONNREQUIRED are mutually exclusive.
*/
#define PR_ATOMIC 0x01 /* exchange atomic messages only */
#define PR_ADDR 0x02 /* addresses given with messages */
#define PR_CONNREQUIRED 0x04 /* connection required by protocol */
#define PR_WANTRCVD 0x08 /* want PRU_RCVD calls */
#define PR_RIGHTS 0x10 /* passes capabilities */
#define PR_ABRTACPTDIS 0x20 /* abort on accept(2) to disconnected
socket */
#define PR_SLOWHZ 2 /* 2 timeouts per second... */
#define PR_FASTHZ 5 /* 5 timeouts per second */
/*
* Defines for the userreq function req field are below.
*
* (*usrreq)(up, req, m, nam, opt);
*
* up is a (struct socket *)
* req is one of these requests,
* m is a optional mbuf chain containing a message,
* nam is an optional mbuf chain containing an address,
* opt is a pointer to a socketopt structure or nil.
*
* The protocol is responsible for disposal of the mbuf chain m,
* the caller is responsible for any space held by nam and opt.
* A non-zero return from usrreq gives an
* UNIX error number which should be passed to higher level software.
*/
#define PRU_ATTACH 0 /* attach protocol to up */
#define PRU_DETACH 1 /* detach protocol from up */
#define PRU_BIND 2 /* bind socket to address */
#define PRU_LISTEN 3 /* listen for connection */
#define PRU_CONNECT 4 /* establish connection to peer */
#define PRU_ACCEPT 5 /* accept connection from peer */
#define PRU_DISCONNECT 6 /* disconnect from peer */
#define PRU_SHUTDOWN 7 /* won't send any more data */
#define PRU_RCVD 8 /* have taken data; more room now */
#define PRU_SEND 9 /* send this data */
#define PRU_ABORT 10 /* abort (fast DISCONNECT, DETATCH) */
#define PRU_CONTROL 11 /* control operations on protocol */
#define PRU_SENSE 12 /* return status into m */
#define PRU_RCVOOB 13 /* retrieve out of band data */
#define PRU_SENDOOB 14 /* send out of band data */
#define PRU_SOCKADDR 15 /* fetch socket's address */
#define PRU_PEERADDR 16 /* fetch peer's address */
#define PRU_CONNECT2 17 /* connect two sockets */
/* begin for protocols internal use */
#define PRU_FASTTIMO 18 /* 200ms timeout */
#define PRU_SLOWTIMO 19 /* 500ms timeout */
#define PRU_PROTORCV 20 /* receive from below */
#define PRU_PROTOSEND 21 /* send to below */
#define PRU_PEEREID 22 /* get local peer eid */
#define PRU_NREQ 22
/*
* The arguments to the ctlinput routine are
* (*protosw[].pr_ctlinput)(cmd, sa, arg);
* where cmd is one of the commands below, sa is a pointer to a sockaddr,
* and arg is an optional caddr_t argument used within a protocol family.
*/
#define PRC_IFDOWN 0 /* interface transition */
#define PRC_ROUTEDEAD 1 /* select new route if possible ??? */
#define PRC_MTUINC 2 /* increase in mtu to host */
#define PRC_QUENCH2 3 /* DEC congestion bit says slow down */
#define PRC_QUENCH 4 /* some one said to slow down */
#define PRC_MSGSIZE 5 /* message size forced drop */
#define PRC_HOSTDEAD 6 /* host appears to be down */
#define PRC_HOSTUNREACH 7 /* deprecated (use PRC_UNREACH_HOST) */
#define PRC_UNREACH_NET 8 /* no route to network */
#define PRC_UNREACH_HOST 9 /* no route to host */
#define PRC_UNREACH_PROTOCOL 10 /* dst says bad protocol */
#define PRC_UNREACH_PORT 11 /* bad port # */
/* was PRC_UNREACH_NEEDFRAG 12 (use PRC_MSGSIZE) */
#define PRC_UNREACH_SRCFAIL 13 /* source route failed */
#define PRC_REDIRECT_NET 14 /* net routing redirect */
#define PRC_REDIRECT_HOST 15 /* host routing redirect */
#define PRC_REDIRECT_TOSNET 16 /* redirect for type of service & net */
#define PRC_REDIRECT_TOSHOST 17 /* redirect for tos & host */
#define PRC_TIMXCEED_INTRANS 18 /* packet lifetime expired in transit */
#define PRC_TIMXCEED_REASS 19 /* lifetime expired on reass q */
#define PRC_PARAMPROB 20 /* header incorrect */
#define PRC_NCMDS 21
#define PRC_IS_REDIRECT(cmd) \
((cmd) >= PRC_REDIRECT_NET && (cmd) <= PRC_REDIRECT_TOSHOST)
/* Network stack defines... */
#ifdef _NETWORK_STACK
struct protosw *protocols;
void add_protocol(struct protosw *pr, int fam);
void remove_protocol(struct protosw *pr);
#endif
struct protosw *pffindproto(int domain, int protocol, int type);
struct protosw *pffindtype(int domain, int type);
#endif /* PROTOSW_H */
+251
View File
@@ -0,0 +1,251 @@
/* sys/socket.h */
#ifndef _SYS_SOCKET_H
#define _SYS_SOCKET_H
#include <OS.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
/* These are the address/protocol families we'll be using... */
/* NB these should be added to as required... */
/* If we want to have Binary compatability we may need to alter these
* to agree with the Be versions...
*/
#define AF_UNSPEC 0
#define AF_LOCAL 1
#define AF_UNIX AF_LOCAL /* for compatability */
#define AF_INET 2
#define AF_ROUTE 3
#define AF_IMPLINK 4
#define AF_LINK 18
#define AF_IPX 23
#define AF_INET6 24
#define AF_MAX 24
#define PF_UNSPEC AF_UNSPEC
#define PF_INET AF_INET
#define PF_ROUTE AF_ROUTE
#define PF_LINK AF_LINK
#define PF_INET6 AF_INET6
#define PF_IPX AF_IPX
#define PF_IMPLINK AF_IMPLINK
/* Types of socket we can create (eventually) */
#define SOCK_DGRAM 10
#define SOCK_STREAM 11
#define SOCK_RAW 12
#define SOCK_MISC 255
/*
* Option flags per-socket.
*/
#define SO_DEBUG 0x0001 /* turn on debugging info recording */
#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
#define SO_REUSEADDR 0x0004 /* allow local address reuse */
#define SO_KEEPALIVE 0x0008 /* keep connections alive */
#define SO_DONTROUTE 0x0010 /* just use interface addresses */
#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
#define SO_LINGER 0x0080 /* linger on close if data present */
#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
#define SO_REUSEPORT 0x0200 /* allow local address & port reuse */
#define SOL_SOCKET 0xffff
/*
* Additional options, not kept in so_options.
*/
#define SO_SNDBUF 0x1001 /* send buffer size */
#define SO_RCVBUF 0x1002 /* receive buffer size */
#define SO_SNDLOWAT 0x1003 /* send low-water mark */
#define SO_RCVLOWAT 0x1004 /* receive low-water mark */
#define SO_SNDTIMEO 0x1005 /* send timeout */
#define SO_RCVTIMEO 0x1006 /* receive timeout */
#define SO_ERROR 0x1007 /* get error status and clear */
#define SO_TYPE 0x1008 /* get socket type */
#define SO_NETPROC 0x1020 /* multiplex; network processing */
/*
* These are the valid values for the "how" field used by shutdown(2).
*/
#define SHUT_RD 1
#define SHUT_WR 2
#define SHUT_RDWR 3
struct linger {
int l_onoff;
int l_linger;
};
struct sockaddr {
uint8 sa_len;
uint8 sa_family;
uint8 sa_data[30];
};
/* this can hold ANY sockaddr we care to throw at it! */
struct sockaddr_storage {
uint8 ss_len; /* total length */
uint8 ss_family; /* address family */
uint8 __ss_pad1[6]; /* align to quad */
uint64 __ss_pad2; /* force alignment for stupid compilers */
uint8 __ss_pad3[240]; /* pad to a total of 256 bytes */
};
struct sockproto {
uint16 sp_family;
uint16 sp_protocol;
};
#define CTL_NET 4
#define CTL_NET_NAMES { \
{ 0, 0 }, \
{ "unix", CTLTYPE_NODE }, \
{ "inet", CTLTYPE_NODE }, \
{ "implink", CTLTYPE_NODE }, \
{ "pup", CTLTYPE_NODE }, \
{ "chaos", CTLTYPE_NODE }, \
{ "xerox_ns", CTLTYPE_NODE }, \
{ "iso", CTLTYPE_NODE }, \
{ "emca", CTLTYPE_NODE }, \
{ "datakit", CTLTYPE_NODE }, \
{ "ccitt", CTLTYPE_NODE }, \
{ "ibm_sna", CTLTYPE_NODE }, \
{ "decnet", CTLTYPE_NODE }, \
{ "dec_dli", CTLTYPE_NODE }, \
{ "lat", CTLTYPE_NODE }, \
{ "hylink", CTLTYPE_NODE }, \
{ "appletalk", CTLTYPE_NODE }, \
{ "route", CTLTYPE_NODE }, \
{ "link_layer", CTLTYPE_NODE }, \
{ "xtp", CTLTYPE_NODE }, \
{ "coip", CTLTYPE_NODE }, \
{ "cnt", CTLTYPE_NODE }, \
{ "rtip", CTLTYPE_NODE }, \
{ "ipx", CTLTYPE_NODE }, \
{ "inet6", CTLTYPE_NODE }, \
{ "pip", CTLTYPE_NODE }, \
{ "isdn", CTLTYPE_NODE }, \
{ "natm", CTLTYPE_NODE }, \
{ "encap", CTLTYPE_NODE }, \
{ "sip", CTLTYPE_NODE }, \
{ "key", CTLTYPE_NODE }, \
}
/*
* PF_ROUTE - Routing table
*
* Three additional levels are defined:
* Fourth: address family, 0 is wildcard
* Fifth: type of info, defined below
* Sixth: flag(s) to mask with for NET_RT_FLAGS
*/
#define NET_RT_DUMP 1 /* dump; may limit to a.f. */
#define NET_RT_FLAGS 2 /* by flags, e.g. RESOLVING */
#define NET_RT_IFLIST 3 /* survey interface list */
#define NET_RT_MAXID 4
#define CTL_NET_RT_NAMES { \
{ 0, 0 }, \
{ "dump", CTLTYPE_STRUCT }, \
{ "flags", CTLTYPE_STRUCT }, \
{ "iflist", CTLTYPE_STRUCT }, \
}
/* Max listen queue for a socket */
#define SOMAXCONN 5 /* defined as 128 in OpenBSD */
struct msghdr {
char * msg_name; /* address we're using (optional) */
uint msg_namelen; /* length of address */
struct iovec *msg_iov; /* scatter/gather array we'll use */
uint msg_iovlen; /* # elements in msg_iov */
char * msg_control; /* extra data */
uint msg_controllen; /* length of extra data */
int msg_flags; /* flags */
};
/* Defines used in msghdr structure. */
#define MSG_OOB 0x1 /* process out-of-band data */
#define MSG_PEEK 0x2 /* peek at incoming message */
#define MSG_DONTROUTE 0x4 /* send without using routing tables */
#define MSG_EOR 0x8 /* data completes record */
#define MSG_TRUNC 0x10 /* data discarded before delivery */
#define MSG_CTRUNC 0x20 /* control data lost before delivery */
#define MSG_WAITALL 0x40 /* wait for full request or error */
#define MSG_DONTWAIT 0x80 /* this message should be nonblocking */
#define MSG_BCAST 0x100 /* this message rec'd as broadcast */
#define MSG_MCAST 0x200 /* this message rec'd as multicast */
struct cmsghdr {
uint cmsg_len;
int cmsg_level;
int cmsg_type;
/* there now follows uchar[] cmsg_data */
};
#define SIOCSHIWAT _IOW('s', 0, int) /* set high watermark */
#define SIOCGHIWAT _IOR('s', 1, int) /* get high watermark */
#define SIOCSLOWAT _IOW('s', 2, int) /* set low watermark */
#define SIOCGLOWAT _IOR('s', 3, int) /* get low watermark */
#define SIOCATMARK _IOR('s', 7, int) /* at oob mark? */
#define SIOCADDRT _IOW('r', 10, struct ortentry) /* add route */
#define SIOCDELRT _IOW('r', 11, struct ortentry) /* delete route */
#define SIOCSIFADDR _IOW('i', 12, struct ifreq) /* set ifnet address */
#define OSIOCGIFADDR _IOWR('i', 13, struct ifreq) /* get ifnet address */
#define SIOCGIFADDR _IOWR('i', 33, struct ifreq) /* get ifnet address */
#define SIOCSIFDSTADDR _IOW('i', 14, struct ifreq) /* set p-p address */
#define OSIOCGIFDSTADDR _IOWR('i', 15, struct ifreq) /* get p-p address */
#define SIOCGIFDSTADDR _IOWR('i', 34, struct ifreq) /* get p-p address */
#define SIOCSIFFLAGS _IOW('i', 16, struct ifreq) /* set ifnet flags */
#define SIOCGIFFLAGS _IOWR('i', 17, struct ifreq) /* get ifnet flags */
#define OSIOCGIFBRDADDR _IOWR('i', 18, struct ifreq) /* get broadcast addr */
#define SIOCGIFBRDADDR _IOWR('i', 35, struct ifreq) /* get broadcast addr */
#define SIOCSIFBRDADDR _IOW('i', 19, struct ifreq) /* set broadcast addr */
#define OSIOCGIFCONF _IOWR('i', 20, struct ifconf) /* get ifnet list */
#define SIOCGIFCONF _IOWR('i', 36, struct ifconf) /* get ifnet list */
#define OSIOCGIFNETMASK _IOWR('i', 21, struct ifreq) /* get net addr mask */
#define SIOCGIFNETMASK _IOWR('i', 37, struct ifreq) /* get net addr mask */
#define SIOCSIFNETMASK _IOW('i', 22, struct ifreq) /* set net addr mask */
#define SIOCGIFMETRIC _IOWR('i', 23, struct ifreq) /* get IF metric */
#define SIOCSIFMETRIC _IOW('i', 24, struct ifreq) /* set IF metric */
#define SIOCDIFADDR _IOW('i', 25, struct ifreq) /* delete IF addr */
#define SIOCAIFADDR _IOW('i', 26, struct ifaliasreq)/* add/chg IF alias */
#define SIOCGIFDATA _IOWR('i', 27, struct ifreq) /* get if_data */
#define SIOCGIFMTU _IOWR('i', 126, struct ifreq) /* get ifnet MTU */
#define SIOCSIFMTU _IOW('i', 127, struct ifreq) /* set ifnet MTU */
#define SIOCADDMULTI _IOW('i', 49, struct ifreq) /* add m'cast addr */
#define SIOCDELMULTI _IOW('i', 50, struct ifreq) /* del m'cast addr */
#ifndef _KERNEL_MODE
/* Function declarations */
int socket (int, int, int);
int bind(int, const struct sockaddr *, int);
int connect(int, const struct sockaddr *, int);
int listen(int, int);
int accept(int, struct sockaddr *, int *);
int closesocket(int);
int shutdown(int sock, int how);
ssize_t send(int, const void *, size_t, int);
ssize_t recv(int, void *, size_t, int);
ssize_t sendto(int, const void *, size_t, int, const struct sockaddr *, size_t);
ssize_t recvfrom(int, void *, size_t, int, struct sockaddr *, size_t *);
int setsockopt(int, int, int, const void *, size_t);
int getsockopt(int, int, int, void *, size_t *);
int getpeername(int, struct sockaddr *, int *);
int getsockname(int, struct sockaddr *, int *);
#endif /* _KERNEL_MODE_ */
#endif /* _SYS_SOCKET_H */
+236
View File
@@ -0,0 +1,236 @@
/* socketvar.h */
#ifndef SYS_SOCKETVAR_H
#define SYS_SOCKETVAR_H
#include <OS.h>
#include <mbuf.h>
#include <sys/uio.h>
#include <sys/socket.h>
struct sockbuf {
uint32 sb_cc; /* actual chars in buffer */
uint32 sb_hiwat; /* max actual char count (high water mark) */
uint32 sb_mbcnt; /* chars of mbufs used */
uint32 sb_mbmax; /* max chars of mbufs to use */
int32 sb_lowat; /* low water mark */
struct mbuf *sb_mb; /* the mbuf chain */
int16 sb_flags; /* flags, see below */
int32 sb_timeo; /* timeout for read/write */
sem_id sb_sleep; /* our sleep sem */
sem_id sb_pop; /* sem to wait on... */
};
#define SB_MAX (256*1024) /* default for max chars in sockbuf */
#define SB_LOCK 0x01 /* lock on data queue */
#define SB_WANT 0x02 /* someone is waiting to lock */
#define SB_WAIT 0x04 /* someone is waiting for data/space */
#define SB_SEL 0x08 /* someone is selecting */
#define SB_ASYNC 0x10 /* ASYNC I/O, need signals */
#define SB_NOINTR 0x40 /* operations not interruptible */
#define SB_KNOTE 0x80 /* kernel note attached */
#define SB_NOTIFY (SB_WAIT|SB_SEL|SB_ASYNC)
typedef void (*socket_event_callback)(void * socket, uint32 event, void * cookie);
struct socket {
uint16 so_type; /* type of socket */
uint16 so_options; /* socket options */
int16 so_linger; /* dreaded linger value */
int16 so_state; /* socket state */
char *so_pcb; /* pointer to the control block */
sem_id so_lock; /* socket lock */
sem_id so_timeo; /* our wait channel */
struct protosw *so_proto; /* pointer to protocol module */
struct socket *so_head;
struct socket *so_q0;
struct socket *so_q;
int16 so_q0len;
int16 so_qlen;
int16 so_qlimit;
int32 so_error;
// pid_t so_pgid;
uint32 so_oobmark;
/* our send/recv buffers */
struct sockbuf so_snd;
struct sockbuf so_rcv;
// event callback
socket_event_callback event_callback;
void * event_callback_cookie;
int sel_ev;
};
/* Select event bit mask */
#define SEL_READ 0x01
#define SEL_WRITE 0x02
#define SEL_EX 0x04
/*
* Socket state bits.
*/
#define SS_NOFDREF 0x001 /* no file table ref any more */
#define SS_ISCONNECTED 0x002 /* socket connected to a peer */
#define SS_ISCONNECTING 0x004 /* in process of connecting to peer */
#define SS_ISDISCONNECTING 0x008 /* in process of disconnecting */
#define SS_CANTSENDMORE 0x010 /* can't send more data to peer */
#define SS_CANTRCVMORE 0x020 /* can't receive more data from peer */
#define SS_RCVATMARK 0x040 /* at mark on input */
#define SS_ISDISCONNECTED 0x800 /* socket disconnected from peer */
#define SS_PRIV 0x080 /* privileged for broadcast, raw... */
#define SS_NBIO 0x100 /* non-blocking ops */
#define SS_ASYNC 0x200 /* async i/o notify */
#define SS_ISCONFIRMING 0x400 /* deciding to accept connection req */
#define SS_CONNECTOUT 0x1000 /* connect, not accept, at this end */
/* helpful defines... */
/* adjust counters in sb reflecting freeing of m */
#define sbfree(sb, m) { \
(sb)->sb_cc -= (m)->m_len; \
(sb)->sb_mbcnt -= MSIZE; \
if ((m)->m_flags & M_EXT) \
(sb)->sb_mbcnt -= (m)->m_ext.ext_size; \
}
#define sbspace(sb) \
((uint32) min((int)((sb)->sb_hiwat - (sb)->sb_cc), \
(int)((sb)->sb_mbmax - (sb)->sb_mbcnt)))
/* do we have to send all at once on a socket? */
#define sosendallatonce(so) \
((so)->so_proto->pr_flags & PR_ATOMIC)
/* adjust counters in sb reflecting allocation of m */
#define sballoc(sb, m) { \
(sb)->sb_cc += (m)->m_len; \
(sb)->sb_mbcnt += MSIZE; \
if ((m)->m_flags & M_EXT) \
(sb)->sb_mbcnt += (m)->m_ext.ext_size; \
}
#define soreadable(so) \
((so)->so_rcv.sb_cc >= (so)->so_rcv.sb_lowat || \
((so)->so_state & SS_CANTRCVMORE) || \
(so)->so_qlen || (so)->so_error)
#define sowriteable(so) \
((sbspace(&(so)->so_snd) >= (so)->so_snd.sb_lowat) && \
(((so)->so_state & SS_ISCONNECTED) || \
(((so)->so_proto->pr_flags & PR_CONNREQUIRED) == 0) || \
((so)->so_state & SS_CANTSENDMORE) || (so)->so_error))
#define M_WAITOK 0x0000
#define M_NOWAIT 0x0001
/*
* Set lock on sockbuf sb; sleep if lock is already held.
* Unless SB_NOINTR is set on sockbuf, sleep is interruptible.
* Returns error without lock if sleep is interrupted.
*/
#define sblock(sb, wf) ((sb)->sb_flags & SB_LOCK ? \
(((wf) == M_WAITOK) ? sb_lock(sb) : EWOULDBLOCK) : \
((sb)->sb_flags |= SB_LOCK), 0)
/* release lock on sockbuf sb */
#define sbunlock(sb) { \
(sb)->sb_flags &= ~SB_LOCK; \
if ((sb)->sb_flags & SB_WANT) { \
(sb)->sb_flags &= ~SB_WANT; \
wakeup((sb)->sb_sleep); \
} \
}
#define sorwakeup(so) sowakeup((so), &(so)->so_rcv)
/* we don't handle upcall for sockets */
#define sowwakeup(so) sowakeup((so), &(so)->so_snd)
#ifdef _KERNEL_MODE
uint32 sb_max;
/* Function prototypes */
/* These are the ones we export to libnet.so */
int initsocket(void **);
int socreate (int, struct socket **, int, int);
int soshutdown(void *, int);
int soclose (void *);
int sobind (void *, char *, int);
int solisten (void *, int);
int soconnect (void *, char *, int);
int soaccept (void *, void **, void *, int *);
int writeit (void *, struct iovec *, int);
int readit (void *, struct iovec *, int *);
int sendit (void *, struct msghdr *, int, int *);
int recvit (void *, struct msghdr *, char *, int *);
//int so_ioctl (void *, int, void *, size_t);
int sosysctl (int *, uint, void *, size_t *, void *, size_t);
int sosetopt (void *, int, int, const void *, size_t);
int sogetopt (void *, int, int, void *, size_t *);
int sogetpeername(void *, struct sockaddr *, int *);
int sogetsockname(void *, struct sockaddr *, int *);
/* these are all private to the stack...although may be shared with
* other network modules.
*/
int sosend(struct socket *so, struct mbuf *addr, struct uio *uio,
struct mbuf *top, struct mbuf *control, int flags);
struct socket *sonewconn(struct socket *head, int connstatus);
int set_socket_event_callback(void *, socket_event_callback, void *, int);
int soreserve (struct socket *so, uint32 sndcc, uint32 rcvcc);
void sbrelease (struct sockbuf *sb);
int sbreserve (struct sockbuf *sb, uint32 cc);
void sbdrop (struct sockbuf *sb, int len);
void sbdroprecord (struct sockbuf *sb);
void sbflush (struct sockbuf *sb);
int sbwait (struct sockbuf *sb);
void sbappend (struct sockbuf *sb, struct mbuf *m);
int sbappendaddr (struct sockbuf *sb, struct sockaddr *asa,
struct mbuf *m0, struct mbuf *control);
int sbappendcontrol (struct sockbuf *sb, struct mbuf *m0,
struct mbuf *control);
void sbappendrecord (struct sockbuf *sb, struct mbuf *m0);
void sbcheck (struct sockbuf *sb);
void sbcompress (struct sockbuf *sb, struct mbuf *m, struct mbuf *n);
int soreceive (struct socket *so, struct mbuf **paddr, struct uio *uio,
struct mbuf **mp0, struct mbuf **controlp, int *flagsp);
void sowakeup(struct socket *so, struct sockbuf *sb);
int sbwait(struct sockbuf *sb);
int sodisconnect(struct socket *);
void sofree(struct socket *);
void sohasoutofband(struct socket *so);
void socantsendmore(struct socket *so);
void socantrcvmore(struct socket *so);
void soisconnected (struct socket *so);
void soisconnecting (struct socket *so);
void soisdisconnected (struct socket *so);
void soisdisconnecting (struct socket *so);
void soqinsque (struct socket *head, struct socket *so, int q);
int soqremque (struct socket *so, int q);
int sorflush(struct socket *so);
int sb_lock(struct sockbuf *sb);
int nsleep(sem_id chan, char *msg, int timeo);
void wakeup(sem_id chan);
#endif /* _NETWORK_STACK */
#endif /* SYS_SOCKETVAR_H */
+229
View File
@@ -0,0 +1,229 @@
/*-
* Copyright (c) 1982, 1986, 1989, 1993
* The Regents of the University of California. All rights reserved.
* (c) UNIX System Laboratories, Inc.
* All or some portions of this file are derived from material licensed
* to the University of California by American Telephone and Telegraph
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
* the permission of UNIX System Laboratories, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)stat.h 8.9 (Berkeley) 8/17/94
*/
#ifndef _SYS_STAT_H_
#define _SYS_STAT_H_
//#include <sys/time.h>
/**
* @file stat.h
* @brief Stat structures and defines
*/
/**
* @defgroup OpenBeOS_POSIX POSIX Headers
* @brief Headers to provide the POSIX layer
*/
/**
* @defgroup Stat sys/stat.h
* @brief Structures and prototypes for stat operations
* @ingroup OpenBeOS_POSIX
* @{
*/
/* XXX - some types we don't yet have in sys/types.h (because we don't yet
* have a sys/types.h and these aren't in ktypes.h!)
*/
#ifdef _KERNEL_MODE_
struct ostat {
mode_t st_mode; /* inode protection mode */
ino_t st_ino; /* inode's number */
uint16 st_dev; /* inode's device */
nlink_t st_nlink; /* number of hard links */
uid_t st_uid; /* user ID of the file's owner */
gid_t st_gid; /* group ID of the file's group */
off_t st_size; /* file size, in bytes */
time_t st_atime; /* time of last access */
time_t st_mtime; /* time of last data modification */
time_t st_ctime; /* time of last file status change */
int64 st_blocks; /* blocks allocated for file */
int32 st_blksize; /* optimal blocksize for I/O */
};
#endif /* _KERNEL_MODE_ */
/* XXX - The stat structure, as defined by POSIX.
* Just implement what we can for the time being.
*/
struct stat {
mode_t st_mode; /* File mode */
ino_t st_ino; /* vnode_id */
// dev_t st_dev; /* inode's device */
nlink_t st_nlink; /* number of hard links */
uid_t st_uid; /* user ID of the file's owner */
gid_t st_gid; /* group ID of the file's group */
off_t st_size; /* file size, in bytes */
time_t st_atime; /* time of last access */
time_t st_mtime; /* time of last data modification */
time_t st_ctime; /* time of last file status change */
int64 st_blocks; /* blocks allocated for file */
uint32 st_blksize; /* optimal blocksize for I/O */
};
/**
* @defgroup POSIX_filemodes File mode defines
* @brief Defines of the file modes we allow
* @ingroup Stat
*@{
*/
/** set user id on execution */
#define S_ISUID 0004000
/** set group id on execution */
#define S_ISGID 0002000
/** sticky bit */
#define S_ISTXT 0001000
/**
* @def S_IRWXU RWX mask for owner
* @def S_IRUSR R for owner
* @def S_IWUSR W for owner
* @def S_IXUSR X for owner
*/
#define S_IRWXU 0000700
#define S_IRUSR 0000400
#define S_IWUSR 0000200
#define S_IXUSR 0000100
/* @def S_IRWXG RWX mask for group
* @def S_IWGRP W for group
* @def S_IRGRP R for group
* @def S_IXGRP X for group
*/
#define S_IRWXG 0000070
#define S_IRGRP 0000040
#define S_IWGRP 0000020
#define S_IXGRP 0000010
#define S_IRWXO 0000007 /* RWX mask for other */
#define S_IROTH 0000004 /* R for other */
#define S_IWOTH 0000002 /* W for other */
#define S_IXOTH 0000001 /* X for other */
#define S_IFMT 0170000
#define S_IFSOCK 0140000
#define S_IFIFO 0010000
#define S_IFCHR 0020000
#define S_IFDIR 0040000
#define S_IFBLK 0060000
#define S_IFREG 0100000
#define S_IFLNK 0120000
#define S_IFWHT 0160000
#define S_ISVTX 0001000
#define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */
#define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */
#define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */
#define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */
#define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */
#define S_ISLNK(m) ((m & 0170000) == 0120000) /* symbolic link */
#define S_ISSOCK(m) ((m & 0170000) == 0140000)/* socket */
#define S_ISWHT(m)((m & 0170000) == 0160000)/* whiteout */
/** 00777 */
#define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO)
/** 07777 */
#define ALLPERMS (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO)
/** 00666 */
#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
/** @} */
/*
* Definitions of flags stored in file flags word.
*
* Super-user and owner changeable flags.
*/
#define UF_SETTABLE 0x0000ffff /* mask of owner changeable flags */
#define UF_NODUMP 0x00000001 /* do not dump file */
#define UF_IMMUTABLE 0x00000002 /* file may not be changed */
#define UF_APPEND 0x00000004 /* writes to file may only append */
#define UF_OPAQUE 0x00000008 /* directory is opaque wrt. union */
/*
* Super-user changeable flags.
*/
#define SF_SETTABLE 0xffff0000 /* mask of superuser changeable flags */
#define SF_ARCHIVED 0x00010000 /* file is archived */
#define SF_IMMUTABLE 0x00020000 /* file may not be changed */
#define SF_APPEND 0x00040000 /* writes to file may only append */
#ifdef _KERNEL_MODE
/*
* Shorthand abbreviations of above.
*/
#define OPAQUE (UF_OPAQUE)
#define APPEND (UF_APPEND | SF_APPEND)
#define IMMUTABLE (UF_IMMUTABLE | SF_IMMUTABLE)
#endif /* _KERNEL_MODE */
#ifndef _KERNEL_MODE_
//#include <sys/cdefs.h>
/** @fn int chmod(const char *path, mode_t mode)
* Changes the file protection modes to those given by mode
*
* @ref POISX_filemodes
*/
int chmod (const char *, mode_t);
/** @fn int fstat(int fd, struct stat *stat)
* get file information on a file identified by descriptor fd
*
* @ref stat
*/
int fstat (int, struct stat *);
//int mknod (const char *, mode_t, dev_t);
int mkdir (const char *, mode_t);
int mkfifo (const char *, mode_t);
/** @fn int stat(const char *path, struct stat *stat)
* Get file information for file path and store it in the structure
* stat
*
* @ref stat
*/
int stat (const char *, struct stat *);
mode_t umask (mode_t);
int fchmod (int, mode_t);
int lstat (const char *, struct stat *);
#endif
/** @} */
#endif /* !_SYS_STAT_H_ */
+41
View File
@@ -0,0 +1,41 @@
/* uio.h */
#ifndef _SYS_UIO_H
#define _SYS_UIO_H
#include <ktypes.h>
typedef struct iovec {
void *iov_base;
size_t iov_len;
} iovec;
#ifdef _KERNEL_MODE
enum uio_rw { UIO_READ, UIO_WRITE };
/* Segment flag values. */
enum uio_seg {
UIO_USERSPACE, /* from user data space */
UIO_SYSSPACE /* from system space */
};
struct uio {
struct iovec *uio_iov; /* pointer to array of iovecs */
int uio_iovcnt; /* number of iovecs in array */
off_t uio_offset; /* offset into file this uio corresponds to */
size_t uio_resid; /* residual i/o count */
enum uio_seg uio_segflg; /* see above */
enum uio_rw uio_rw; /* see above */
// struct proc *uio_procp; /* process if UIO_USERSPACE */
};
int uiomove(char *cp, int n, struct uio *uio);
#endif
ssize_t readv(int fd, const struct iovec *vector, size_t count);
ssize_t readv_pos(int fd, off_t pos, const struct iovec *vec, size_t count);
ssize_t writev(int fd, const struct iovec *vector, size_t count);
ssize_t writev_pos(int fd, off_t pos, const struct iovec *vec, size_t count);
#endif /* _SYS_UIO_H */
+128
View File
@@ -0,0 +1,128 @@
/*
** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#ifndef _LIBSYS_SYSCALLS_H
#define _LIBSYS_SYSCALLS_H
#include <ktypes.h>
#include <types.h>
#include <defines.h>
#include <resource.h>
#include <vfs_types.h>
#include <vm_types.h>
#include <thread_types.h>
#include <OS.h>
#include <sys/stat.h>
#ifdef __cplusplus
extern "C" {
#endif
int sys_null();
/* fs api */
int sys_mount(const char *path, const char *device, const char *fs_name, void *args);
int sys_unmount(const char *path);
int sys_sync();
int sys_open(const char *path, stream_type st, int omode);
int sys_close(int fd);
int sys_fsync(int fd);
ssize_t sys_read(int fd, void *buf, off_t pos, size_t len);
ssize_t sys_write(int fd, const void *buf, off_t pos, size_t len);
int sys_seek(int fd, off_t pos, int seek_type);
int sys_ioctl(int fd, ulong op, void *buf);
int sys_create(const char *path, stream_type stream_type);
int sys_unlink(const char *path);
int sys_rename(const char *oldpath, const char *newpath);
int sys_rstat(const char *path, struct stat *stat);
int sys_wstat(const char *path, struct stat *stat, int stat_mask);
int sys_fstat(int, struct stat *);
char *sys_getcwd(char* buf, size_t size);
int sys_setcwd(const char* path);
int sys_dup(int fd);
int sys_dup2(int ofd, int nfd);
bigtime_t sys_system_time();
int sys_snooze(bigtime_t time);
int sys_getrlimit(int resource, struct rlimit * rlp);
int sys_setrlimit(int resource, const struct rlimit * rlp);
/* sem functions */
sem_id kern_create_sem(int count, const char *name);
int kern_delete_sem(sem_id id);
int kern_acquire_sem(sem_id id);
int kern_acquire_sem_etc(sem_id id, int count, int flags, bigtime_t timeout);
int kern_release_sem(sem_id id);
int kern_release_sem_etc(sem_id id, int count, int flags);
int sys_sem_get_count(sem_id id, int32* thread_count);
int kern_get_sem_info(sem_id, struct sem_info *, size_t);
int kern_get_next_sem_info(proc_id, uint32 *, struct sem_info *, size_t);
int sys_set_sem_owner(sem_id id, proc_id proc);
int sys_proc_get_table(struct proc_info *pi, size_t len);
void sys_exit(int retcode);
proc_id sys_proc_create_proc(const char *path, const char *name, char **args, int argc, int priority);
thread_id kern_spawn_thread(int (*func)(void*), const char *, int, void *);
thread_id kern_get_current_thread_id(void);
int kern_suspend_thread(thread_id tid);
int kern_resume_thread(thread_id tid);
int kern_kill_thread(thread_id tid);
int sys_thread_wait_on_thread(thread_id tid, int *retcode);
int sys_proc_kill_proc(proc_id pid);
proc_id sys_get_current_proc_id();
int sys_proc_wait_on_proc(proc_id pid, int *retcode);
region_id sys_vm_create_anonymous_region(const char *name, void **address, int addr_type,
addr size, int wiring, int lock);
region_id sys_vm_clone_region(const char *name, void **address, int addr_type,
region_id source_region, int mapping, int lock);
region_id sys_vm_map_file(const char *name, void **address, int addr_type,
addr size, int lock, int mapping, const char *path, off_t offset);
int sys_vm_delete_region(region_id id);
int sys_vm_get_region_info(region_id id, vm_region_info *info);
/* kernel port functions */
port_id sys_port_create(int32 queue_length, const char *name);
int sys_port_close(port_id id);
int sys_port_delete(port_id id);
port_id sys_port_find(const char *port_name);
int sys_port_get_info(port_id id, struct port_info *info);
int sys_port_get_next_port_info(proc_id proc, uint32 *cookie, struct port_info *info);
ssize_t sys_port_buffer_size(port_id port);
ssize_t sys_port_buffer_size_etc(port_id port, uint32 flags, bigtime_t timeout);
int32 sys_port_count(port_id port);
ssize_t sys_port_read(port_id port, int32 *msg_code, void *msg_buffer, size_t buffer_size);
ssize_t sys_port_read_etc(port_id port, int32 *msg_code, void *msg_buffer, size_t buffer_size, uint32 flags, bigtime_t timeout);
int sys_port_set_owner(port_id port, team_id proc);
int sys_port_write(port_id port, int32 msg_code, const void *msg_buffer, size_t buffer_size);
int sys_port_write_etc(port_id port, int32 msg_code, const void *msg_buffer, size_t buffer_size, uint32 flags, bigtime_t timeout);
/* atomic_* ops (needed for cpus that dont support them directly) */
int sys_atomic_add(int *val, int incr);
int sys_atomic_and(int *val, int incr);
int sys_atomic_or(int *val, int incr);
int sys_atomic_set(int *val, int set_to);
int sys_test_and_set(int *val, int set_to, int test_val);
int sys_sysctl(int *, uint, void *, size_t *, void *, size_t);
int sys_socket(int, int, int);
/* region prototypes */
area_id sys_find_region_by_name(const char *);
/* This is a real BSD'ism :) Basically it returns the size of the
* descriptor table for the current process as an integer.
*/
int kern_getdtablesize(void);
#ifdef __cplusplus
}
#endif
#endif
+172
View File
@@ -0,0 +1,172 @@
#ifndef _KERNEL_THREAD_TYPES_H
#define _KERNEL_THREAD_TYPES_H
/**
* @file kernel/thread_types.h
* @brief Definitions, structures and functions for threads.
*/
/**
* @defgroup Kernel_Threads Threads
* @ingroup OpenBeOS_Kernel
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <stage2.h>
#include <ktypes.h>
#include <vm.h>
#include <smp.h>
#include <arch/thread_struct.h>
#define THREAD_IDLE_PRIORITY 0
#define THREAD_NUM_PRIORITY_LEVELS 64
#define THREAD_MIN_PRIORITY (THREAD_IDLE_PRIORITY + 1)
#define THREAD_MAX_PRIORITY (THREAD_NUM_PRIORITY_LEVELS - THREAD_NUM_RT_PRIORITY_LEVELS - 1)
#define THREAD_NUM_RT_PRIORITY_LEVELS 16
#define THREAD_MIN_RT_PRIORITY (THREAD_MAX_PRIORITY + 1)
#define THREAD_MAX_RT_PRIORITY (THREAD_NUM_PRIORITY_LEVELS - 1)
#define THREAD_LOWEST_PRIORITY THREAD_MIN_PRIORITY
#define THREAD_LOW_PRIORITY 12
#define THREAD_MEDIUM_PRIORITY 24
#define THREAD_HIGH_PRIORITY 36
#define THREAD_HIGHEST_PRIORITY THREAD_MAX_PRIORITY
#define THREAD_RT_LOW_PRIORITY THREAD_MIN_RT_PRIORITY
#define THREAD_RT_HIGH_PRIORITY THREAD_MAX_RT_PRIORITY
extern spinlock_t thread_spinlock;
#define GRAB_THREAD_LOCK() acquire_spinlock(&thread_spinlock)
#define RELEASE_THREAD_LOCK() release_spinlock(&thread_spinlock)
enum {
THREAD_STATE_READY = 0, // ready to run
THREAD_STATE_RUNNING, // running right now somewhere
THREAD_STATE_WAITING, // blocked on something
THREAD_STATE_SUSPENDED, // suspended, not in queue
THREAD_STATE_FREE_ON_RESCHED, // free the thread structure upon reschedule
THREAD_STATE_BIRTH // thread is being created
};
enum {
PROC_STATE_NORMAL, // normal state
PROC_STATE_BIRTH, // being contructed
PROC_STATE_DEATH // being killed
};
#define SIG_NONE 0
#define SIG_SUSPEND 1
#define SIG_KILL 2
/**
* The proc structure.
* @note This is available only within the kernel.
*/
struct proc {
/** Pointer to next proc structure */
struct proc *next;
/** The proc_id for this process.
* @note This is equivalent to a team_id (???)
*/
proc_id id;
/** name of the process
* @note The maximum length is current SYS_MAX_OS_NAME_LEN chars.
*/
char name[SYS_MAX_OS_NAME_LEN];
/** How many threads does this process have? */
int num_threads;
/** Current state of the process. */
int state;
/** Signals pending for the process? */
int pending_signals;
/** Pointer to the I/O context for this process.
* @note see fd.h for definition of ioctx
*/
void *ioctx;
/** Path ??? */
char path[SYS_MAX_PATH_LEN];
/** Our address space pointer */
aspace_id _aspace_id;
vm_address_space *aspace;
vm_address_space *kaspace;
struct thread *main_thread;
struct thread *thread_list;
struct arch_proc arch_info;
};
struct thread {
struct thread *all_next;
struct thread *proc_next;
struct thread *q_next;
thread_id id;
char name[SYS_MAX_OS_NAME_LEN];
int priority;
int state;
int next_state;
union cpu_ent *cpu;
int pending_signals;
bool in_kernel;
sem_id sem_blocking;
int sem_count;
int sem_acquire_count;
int sem_deleted_retcode;
int sem_errcode;
int sem_flags;
addr fault_handler;
addr entry;
void *args;
struct proc *proc;
sem_id return_code_sem;
region_id kernel_stack_region_id;
addr kernel_stack_base;
region_id user_stack_region_id;
addr user_stack_base;
bigtime_t user_time;
bigtime_t kernel_time;
bigtime_t last_time;
// architecture dependant section
struct arch_thread arch_info;
};
struct thread_queue {
struct thread *head;
struct thread *tail;
};
/**
* Process information structure
* @note Seem to be a lot of duplicated fields with main
* proc structure???
*/
struct proc_info {
proc_id id;
char name[SYS_MAX_OS_NAME_LEN];
int state;
int num_threads;
};
#if 1
/**
* Test routine for threads.
* @note This function will be removed as is intended for test and
* development purposes only.
*/
int thread_test(void);
#endif
#ifdef __cplusplus
}
#endif
/** @} */
#endif /* _KERNEL_THREAD_TYPES_H */
+35
View File
@@ -0,0 +1,35 @@
#ifndef VFS_TYPES_H
#define VFS_TYPES_H
#include <sys/uio.h>
typedef enum {
STREAM_TYPE_ANY = 0,
STREAM_TYPE_FILE,
STREAM_TYPE_DIR,
STREAM_TYPE_DEVICE
} stream_type;
typedef void * fs_cookie;
typedef void * file_cookie;
typedef void * fs_vnode;
//typedef struct iovec {
// void *start;
// size_t len;
//} iovec;
typedef struct iovecs {
size_t num;
size_t total_len;
iovec vec[0];
} iovecs;
//struct file_stat {
// vnode_id vnid;
// stream_type type;
// off_t size;
//};
#endif
+183
View File
@@ -0,0 +1,183 @@
#ifndef _PUBLIC_KERNEL_VM_TYPES_H
#define _PUBLIC_KERNEL_VM_TYPES_H
#include <kernel.h>
#include <stage2.h>
#include <defines.h>
#include <vfs.h>
#include <arch/vm_translation_map.h>
// vm page
typedef struct vm_page {
struct vm_page *queue_prev;
struct vm_page *queue_next;
struct vm_page *hash_next;
addr ppn; // physical page number
off_t offset;
struct vm_cache_ref *cache_ref;
struct vm_page *cache_prev;
struct vm_page *cache_next;
unsigned int ref_count;
unsigned int type : 2;
unsigned int state : 3;
} vm_page;
enum {
PAGE_TYPE_PHYSICAL = 0,
PAGE_TYPE_DUMMY,
PAGE_TYPE_GUARD
};
enum {
PAGE_STATE_ACTIVE = 0,
PAGE_STATE_INACTIVE,
PAGE_STATE_BUSY,
PAGE_STATE_MODIFIED,
PAGE_STATE_FREE,
PAGE_STATE_CLEAR,
PAGE_STATE_WIRED,
PAGE_STATE_UNUSED
};
// vm_cache_ref
typedef struct vm_cache_ref {
struct vm_cache *cache;
mutex lock;
struct vm_region *region_list;
int ref_count;
} vm_cache_ref;
// vm_cache
typedef struct vm_cache {
vm_page *page_list;
vm_cache_ref *ref;
struct vm_cache *source;
struct vm_store *store;
off_t virtual_size;
unsigned int temporary : 1;
unsigned int scan_skip : 1;
} vm_cache;
// info about a region that external entities may want to know
// used in vm_get_region_info()
typedef struct vm_region_info {
region_id id;
addr base;
addr size;
int lock;
int wiring;
char name[SYS_MAX_OS_NAME_LEN];
} vm_region_info;
// vm region
typedef struct vm_region {
char *name;
region_id id;
addr base;
addr size;
int lock;
int wiring;
int ref_count;
struct vm_cache_ref *cache_ref;
off_t cache_offset;
struct vm_address_space *aspace;
struct vm_region *aspace_next;
struct vm_virtual_map *map;
struct vm_region *cache_next;
struct vm_region *cache_prev;
struct vm_region *hash_next;
} vm_region;
// virtual map (1 per address space)
typedef struct vm_virtual_map {
vm_region *region_list;
vm_region *region_hint;
int change_count;
sem_id sem;
struct vm_address_space *aspace;
addr base;
addr size;
} vm_virtual_map;
enum {
VM_ASPACE_STATE_NORMAL = 0,
VM_ASPACE_STATE_DELETION
};
// address space
typedef struct vm_address_space {
vm_virtual_map virtual_map;
vm_translation_map translation_map;
char *name;
aspace_id id;
int ref_count;
int fault_count;
int state;
addr scan_va;
addr working_set_size;
addr max_working_set;
addr min_working_set;
bigtime_t last_working_set_adjust;
struct vm_address_space *hash_next;
} vm_address_space;
// vm_store
typedef struct vm_store {
struct vm_store_ops *ops;
struct vm_cache *cache;
void *data;
off_t committed_size;
} vm_store;
// vm_store_ops
typedef struct vm_store_ops {
void (*destroy)(struct vm_store *backing_store);
off_t (*commit)(struct vm_store *backing_store, off_t size);
int (*has_page)(struct vm_store *backing_store, off_t offset);
ssize_t (*read)(struct vm_store *backing_store, off_t offset, iovecs *vecs);
ssize_t (*write)(struct vm_store *backing_store, off_t offset, iovecs *vecs);
int (*fault)(struct vm_store *backing_store, struct vm_address_space *aspace, off_t offset);
void (*acquire_ref)(struct vm_store *backing_store);
void (*release_ref)(struct vm_store *backing_store);
} vm_store_ops;
// args for the create_area funcs
enum {
REGION_ADDR_ANY_ADDRESS = 0,
REGION_ADDR_EXACT_ADDRESS
};
enum {
REGION_NO_PRIVATE_MAP = 0,
REGION_PRIVATE_MAP
};
enum {
REGION_WIRING_LAZY = 0,
REGION_WIRING_WIRED,
REGION_WIRING_WIRED_ALREADY,
REGION_WIRING_WIRED_CONTIG
};
enum {
PHYSICAL_PAGE_NO_WAIT = 0,
PHYSICAL_PAGE_CAN_WAIT,
};
#define LOCK_RO 0x0
#define LOCK_RW 0x1
#define LOCK_KERNEL 0x2
#define LOCK_MASK 0x3
#endif /* _PUBLIC_KERNEL_VM_TYPES_H */
+108
View File
@@ -0,0 +1,108 @@
/*******************************************************************************
/
/ File: Buffer.h
/
/ Description: A BBuffer is a container of media data in the Media Kit
/
/ Copyright 1997-98, Be Incorporated, All Rights Reserved
/
*******************************************************************************/
#if !defined(_BUFFER_H)
#define _BUFFER_H
#include <MediaDefs.h>
/*** A BBuffer is not the same thing as the area segment that gets cloned ***/
/*** For each buffer that gets created, a BBuffer object is created to represent ***/
/*** it in each participant address space. ***/
struct _shared_buffer_list;
struct buffer_clone_info {
buffer_clone_info();
~buffer_clone_info();
media_buffer_id buffer;
area_id area;
size_t offset;
size_t size;
int32 flags;
private:
uint32 _reserved_[4];
};
class BBuffer
{
public:
void * Data(); /* returns NULL if buffer not correctly initialized */
size_t SizeAvailable(); // total size of buffer (how much data can it hold)
size_t SizeUsed(); // how much was written (how much data does it hold)
void SetSizeUsed(
size_t size_used);
uint32 Flags();
void Recycle();
buffer_clone_info CloneInfo() const;
media_buffer_id ID(); /* 0 if not registered */
media_type Type();
media_header * Header();
media_audio_header * AudioHeader();
media_video_header * VideoHeader();
enum { /* for flags */
B_F1_BUFFER = 0x1,
B_F2_BUFFER = 0x2,
B_SMALL_BUFFER = 0x80000000
};
size_t Size(); // deprecated; use SizeAvailable()
private:
friend struct _buffer_id_cache;
friend struct _shared_buffer_list;
friend class BMediaRoster;
friend class BBufferProducer;
friend class BBufferConsumer; /* for buffer receiving */
friend class BBufferGroup;
friend class BSmallBuffer;
explicit BBuffer(const buffer_clone_info & info);
~BBuffer(); /* BBuffer is NOT a virtual class!!! */
BBuffer(); /* not implemented */
BBuffer(const BBuffer & clone); /* not implemented */
BBuffer & operator=(const BBuffer & clone); /* not implemented */
void SetHeader(const media_header *header);
media_header fMediaHeader;
_shared_buffer_list * fBufferList;
area_id fArea;
void * fData;
size_t fOffset;
size_t fSize;
media_buffer_id fBufferID;
int32 fFlags;
uint32 _reserved_buffer_[11];
};
class BSmallBuffer : public BBuffer
{
public:
BSmallBuffer();
static size_t SmallBufferSizeLimit();
};
#endif /* _BUFFER_H */
+203
View File
@@ -0,0 +1,203 @@
/*******************************************************************************
/
/ File: BufferConsumer.h
/
/ Description: A BBufferConsumer is anything that wants to receive buffers in the Media Kit
/
/ Copyright 1997-98, Be Incorporated, All Rights Reserved
/
*******************************************************************************/
#if !defined(_BUFFER_CONSUMER_H)
#define _BUFFER_CONSUMER_H
#include <MediaDefs.h>
#include <MediaNode.h>
class _buffer_id_cache;
class BBufferConsumer :
public virtual BMediaNode
{
protected:
/* this has to be at the top to force a vtable */
virtual ~BBufferConsumer();
public:
media_type ConsumerType();
/* for encoding a region into the format needed for clipping requests */
static status_t RegionToClipData(
const BRegion * region,
int32 * format,
int32 * ioSize,
void * data);
protected:
explicit BBufferConsumer(
media_type consumer_type /* = B_MEDIA_UNKNOWN_TYPE */);
static void NotifyLateProducer(
const media_source & what_source,
bigtime_t how_much,
bigtime_t performance_time);
status_t SetVideoClippingFor(
const media_source & output,
const media_destination & destination,
const int16 * shorts,
int32 short_count,
const media_video_display_info & display,
void * user_data,
int32 * change_tag,
void * _reserved_ = 0); // change_tag value will be passed to RequestCompleted()
status_t SetOutputEnabled(
const media_source & source,
const media_destination & destination,
bool enabled,
void * user_data,
int32 * change_tag,
void * _reserved_ = 0); // change_tag value will be passed to RequestCompleted()
status_t RequestFormatChange(
const media_source & source,
const media_destination & destination,
const media_format & to_format,
void * user_data,
int32 * change_tag,
void * _reserved_ = 0); // change_tag value will be passed to RequestCompleted()
status_t RequestAdditionalBuffer( // new in 4.1
const media_source & source,
BBuffer * prev_buffer,
void * _reserved = NULL);
status_t RequestAdditionalBuffer( // new in 4.1
const media_source & source,
bigtime_t start_time,
void * _reserved = NULL);
status_t SetOutputBuffersFor( // new in 4.1
const media_source & source,
const media_destination & destination,
BBufferGroup * group,
void * user_data,
int32 * change_tag, // passed to RequestCompleted()
bool will_reclaim = false,
void * _reserved_ = 0);
status_t SendLatencyChange(
const media_source & source,
const media_destination & destination,
bigtime_t my_new_latency,
uint32 flags = 0);
protected:
virtual status_t HandleMessage(
int32 message,
const void * data,
size_t size);
/* Someone, probably the producer, is asking you about this format. Give */
/* your honest opinion, possibly modifying *format. Do not ask upstream */
/* producer about the format, since he's synchronously waiting for your */
/* reply. */
virtual status_t AcceptFormat(
const media_destination & dest,
media_format * format) = 0;
virtual status_t GetNextInput(
int32 * cookie,
media_input * out_input) = 0;
virtual void DisposeInputCookie(
int32 cookie) = 0;
virtual void BufferReceived(
BBuffer * buffer) = 0;
virtual void ProducerDataStatus(
const media_destination & for_whom,
int32 status,
bigtime_t at_performance_time) = 0;
virtual status_t GetLatencyFor(
const media_destination & for_whom,
bigtime_t * out_latency,
media_node_id * out_timesource) = 0;
virtual status_t Connected(
const media_source & producer, /* here's a good place to request buffer group usage */
const media_destination & where,
const media_format & with_format,
media_input * out_input) = 0;
virtual void Disconnected(
const media_source & producer,
const media_destination & where) = 0;
/* The notification comes from the upstream producer, so he's already cool with */
/* the format; you should not ask him about it in here. */
virtual status_t FormatChanged(
const media_source & producer,
const media_destination & consumer,
int32 change_tag,
const media_format & format) = 0;
/* Given a performance time of some previous buffer, retrieve the remembered tag */
/* of the closest (previous or exact) performance time. Set *out_flags to 0; the */
/* idea being that flags can be added later, and the understood flags returned in */
/* *out_flags. */
virtual status_t SeekTagRequested(
const media_destination & destination,
bigtime_t in_target_time,
uint32 in_flags,
media_seek_tag * out_seek_tag,
bigtime_t * out_tagged_time,
uint32 * out_flags);
private:
friend class BMediaNode;
BBufferConsumer(); /* private unimplemented */
BBufferConsumer(
const BBufferConsumer & clone);
BBufferConsumer & operator=(
const BBufferConsumer & clone);
// these functions are deprecated from the 4.0 API
static status_t SetVideoClippingFor(
const media_source & output,
const int16 * shorts,
int32 short_count,
const media_video_display_info & display,
int32 * change_tag); // change_tag value will be passed to RequestCompleted()
static status_t RequestFormatChange(
const media_source & source,
const media_destination & destination,
media_format * io_to_format, // the "o" part is unused from 4.1
int32 * change_tag); // change_tag value will be passed to RequestCompleted()
static status_t SetOutputEnabled(
const media_source & source,
bool enabled,
int32 * change_tag); // change_tag value will be passed to RequestCompleted()
/* Mmmh, stuffing! */
status_t _Reserved_BufferConsumer_0(void *); /* SeekTagRequested */
virtual status_t _Reserved_BufferConsumer_1(void *);
virtual status_t _Reserved_BufferConsumer_2(void *);
virtual status_t _Reserved_BufferConsumer_3(void *);
virtual status_t _Reserved_BufferConsumer_4(void *);
virtual status_t _Reserved_BufferConsumer_5(void *);
virtual status_t _Reserved_BufferConsumer_6(void *);
virtual status_t _Reserved_BufferConsumer_7(void *);
virtual status_t _Reserved_BufferConsumer_8(void *);
virtual status_t _Reserved_BufferConsumer_9(void *);
virtual status_t _Reserved_BufferConsumer_10(void *);
virtual status_t _Reserved_BufferConsumer_11(void *);
virtual status_t _Reserved_BufferConsumer_12(void *);
virtual status_t _Reserved_BufferConsumer_13(void *);
virtual status_t _Reserved_BufferConsumer_14(void *);
virtual status_t _Reserved_BufferConsumer_15(void *);
friend class BMediaRoster;
media_type fConsumerType;
_buffer_id_cache * fBufferCache;
BBufferGroup *fDeleteBufferGroup;
uint32 _reserved_buffer_consumer_[14];
};
#endif /* _BUFFER_CONSUMER_H */
+81
View File
@@ -0,0 +1,81 @@
/*******************************************************************************
/
/ File: BufferGroup.h
/
/ Description: A BBufferGroup organizes sets of BBuffers so that you can request
/ and reclaim them.
/
/ Copyright 1997-98, Be Incorporated, All Rights Reserved
/
*******************************************************************************/
#if !defined(_BUFFER_GROUP_H)
#define _BUFFER_GROUP_H
#include <MediaDefs.h>
struct _shared_buffer_list;
class BBufferGroup
{
public:
BBufferGroup(
size_t size,
int32 count = 3,
uint32 placement = B_ANY_ADDRESS,
uint32 lock = B_FULL_LOCK);
explicit BBufferGroup();
BBufferGroup(
int32 count,
const media_buffer_id * buffers);
~BBufferGroup(); /* BBufferGroup is NOT a virtual class!!! */
status_t InitCheck();
/* use this function to add buffers you created on your own */
status_t AddBuffer(
const buffer_clone_info & info,
BBuffer ** out_buffer = NULL);
BBuffer * RequestBuffer(
size_t size,
bigtime_t timeout = B_INFINITE_TIMEOUT);
status_t RequestBuffer(
BBuffer * buffer,
bigtime_t timeout = B_INFINITE_TIMEOUT);
status_t RequestError(); /* return last RequestBuffer error, useful if NULL is returned */
status_t CountBuffers(
int32 * out_count);
status_t GetBufferList(
int32 buf_count,
BBuffer ** out_buffers);
status_t WaitForBuffers();
status_t ReclaimAllBuffers();
private:
/* in BeOS R5 this is a deprecated api, from BeOS R4 times */
status_t AddBuffersTo(BMessage * message, const char * name, bool needLock=true);
status_t InitBufferGroup(); /* used internally */
BBufferGroup(const BBufferGroup &); /* not implemented */
BBufferGroup& operator=(const BBufferGroup&); /* not implemented */
friend struct _shared_buffer_list;
status_t fInitError;
status_t fRequestError;
int32 fBufferCount;
_shared_buffer_list * fBufferList;
// this is a BBufferGroup specific semaphore used for reclaiming BBuffers of this group
// is also is a system wide unique identifier of this group
sem_id fReclaimSem;
uint32 _reserved_buffer_group_[9];
};
#endif /* _BUFFER_GROUP_H */
+239
View File
@@ -0,0 +1,239 @@
/*******************************************************************************
/
/ File: BBufferProducer.h
/
/ Description: A BBufferProducer is any source of media buffers in the Media Kit
/
/ Copyright 1997-98, Be Incorporated, All Rights Reserved
/
*******************************************************************************/
#if !defined(_BUFFER_PRODUCER_H)
#define _BUFFER_PRODUCER_H
#include <MediaDefs.h>
#include <MediaNode.h>
class BBufferProducer :
public virtual BMediaNode
{
protected:
/* this has to be at the top to force a vtable */
virtual ~BBufferProducer();
public:
/* Supported formats for low-level clipping data */
enum {
B_CLIP_SHORT_RUNS = 1
};
/* Handy conversion functions for dealing with clip information */
static status_t ClipDataToRegion(
int32 format,
int32 size,
const void * data,
BRegion * region);
media_type ProducerType();
protected:
explicit BBufferProducer(
media_type producer_type /* = B_MEDIA_UNKNOWN_TYPE */);
enum suggestion_quality {
B_ANY_QUALITY = 0,
B_LOW_QUALITY = 10,
B_MEDIUM_QUALITY = 50,
B_HIGH_QUALITY = 100
};
/* functionality of BBufferProducer */
virtual status_t FormatSuggestionRequested(
media_type type,
int32 quality,
media_format * format) = 0;
virtual status_t FormatProposal(
const media_source & output,
media_format * format) = 0;
/* If the format isn't good, put a good format into *io_format and return error */
/* If format has wildcard, specialize to what you can do (and change). */
/* If you can change the format, return OK. */
/* The request comes from your destination sychronously, so you cannot ask it */
/* whether it likes it -- you should assume it will since it asked. */
virtual status_t FormatChangeRequested(
const media_source & source,
const media_destination & destination,
media_format * io_format,
int32 * _deprecated_) = 0;
virtual status_t GetNextOutput( /* cookie starts as 0 */
int32 * cookie,
media_output * out_output) = 0;
virtual status_t DisposeOutputCookie(
int32 cookie) = 0;
/* In this function, you should either pass on the group to your upstream guy, */
/* or delete your current group and hang on to this group. Deleting the previous */
/* group (unless you passed it on with the reclaim flag set to false) is very */
/* important, else you will 1) leak memory and 2) block someone who may want */
/* to reclaim the buffers living in that group. */
virtual status_t SetBufferGroup(
const media_source & for_source,
BBufferGroup * group) = 0;
/* Format of clipping is (as int16-s): <from line> <npairs> <startclip> <endclip>. */
/* Repeat for each line where the clipping is different from the previous line. */
/* If <npairs> is negative, use the data from line -<npairs> (there are 0 pairs after */
/* a negative <npairs>. Yes, we only support 32k*32k frame buffers for clipping. */
/* Any non-0 field of 'display' means that that field changed, and if you don't support */
/* that change, you should return an error and ignore the request. Note that the buffer */
/* offset values do not have wildcards; 0 (or -1, or whatever) are real values and must */
/* be adhered to. */
virtual status_t VideoClippingChanged(
const media_source & for_source,
int16 num_shorts,
int16 * clip_data,
const media_video_display_info & display,
int32 * _deprecated_);
/* Iterates over all outputs and maxes the latency found */
virtual status_t GetLatency(
bigtime_t * out_lantency);
virtual status_t PrepareToConnect(
const media_source & what,
const media_destination & where,
media_format * format,
media_source * out_source,
char * out_name) = 0;
virtual void Connect(
status_t error,
const media_source & source,
const media_destination & destination,
const media_format & format,
char * io_name) = 0;
virtual void Disconnect(
const media_source & what,
const media_destination & where) = 0;
virtual void LateNoticeReceived(
const media_source & what,
bigtime_t how_much,
bigtime_t performance_time) = 0;
virtual void EnableOutput(
const media_source & what,
bool enabled,
int32 * _deprecated_) = 0;
virtual status_t SetPlayRate(
int32 numer,
int32 denom);
virtual status_t HandleMessage( /* call this from the thread that listens to the port */
int32 message,
const void * data,
size_t size);
virtual void AdditionalBufferRequested( // used to be Reserved 0
const media_source & source,
media_buffer_id prev_buffer,
bigtime_t prev_time,
const media_seek_tag * prev_tag); // may be NULL
virtual void LatencyChanged( // used to be Reserved 1
const media_source & source,
const media_destination & destination,
bigtime_t new_latency,
uint32 flags);
/* Use this function in BBufferProducer to pass on the buffer. */
status_t SendBuffer(
BBuffer * buffer,
const media_destination & destination);
status_t SendDataStatus(
int32 status,
const media_destination & destination,
bigtime_t at_time);
/* Check in advance if a target is prepared to accept a format. You may */
/* want to call this from Connect(), although that's not required. */
status_t ProposeFormatChange(
media_format * format,
const media_destination & for_destination);
/* Tell consumer to accept a proposed format change */
/* YOU MUST NOT CALL BROADCAST_BUFFER WHILE THIS CALL IS OUTSTANDING! */
status_t ChangeFormat(
const media_source & for_source,
const media_destination & for_destination,
media_format * format);
/* Check how much latency the down-stream graph introduces */
status_t FindLatencyFor(
const media_destination & for_destination,
bigtime_t * out_latency,
media_node_id * out_timesource);
/* Find the tag of a previously seen buffer to expedite seeking */
status_t FindSeekTag(
const media_destination & for_destination,
bigtime_t in_target_time,
media_seek_tag * out_tag,
bigtime_t * out_tagged_time,
uint32 * out_flags = 0,
uint32 in_flags = 0);
/* Set the initial latency, which is the maximum additional latency */
/* that will be imposed while starting/syncing to a signal (such as */
/* starting a TV capture card in the middle of a field). Most nodes */
/* have this at 0 (the default); only TV input Nodes need it currently */
/* because they slave to a low-resolution (59.94 Hz) clock that arrives */
/* from the outside world. Call this from the constructor if you need it. */
void SetInitialLatency(
bigtime_t inInitialLatency,
uint32 flags = 0);
private:
friend class BMediaRoster;
friend class BBufferConsumer;
friend class BMediaNode;
BBufferProducer(); /* private unimplemented */
BBufferProducer(
const BBufferProducer & clone);
BBufferProducer & operator=(
const BBufferProducer & clone);
/* Mmmh, stuffing! */
status_t _Reserved_BufferProducer_0(void *); /* AdditionalBufferRequested() */
status_t _Reserved_BufferProducer_1(void *); /* LatencyChanged() */
virtual status_t _Reserved_BufferProducer_2(void *);
virtual status_t _Reserved_BufferProducer_3(void *);
virtual status_t _Reserved_BufferProducer_4(void *);
virtual status_t _Reserved_BufferProducer_5(void *);
virtual status_t _Reserved_BufferProducer_6(void *);
virtual status_t _Reserved_BufferProducer_7(void *);
virtual status_t _Reserved_BufferProducer_8(void *);
virtual status_t _Reserved_BufferProducer_9(void *);
virtual status_t _Reserved_BufferProducer_10(void *);
virtual status_t _Reserved_BufferProducer_11(void *);
virtual status_t _Reserved_BufferProducer_12(void *);
virtual status_t _Reserved_BufferProducer_13(void *);
virtual status_t _Reserved_BufferProducer_14(void *);
virtual status_t _Reserved_BufferProducer_15(void *);
media_type fProducerType;
bigtime_t fInitialLatency;
uint32 fInitialFlags;
static status_t clip_shorts_to_region(
const int16 * data,
int count,
BRegion * output);
static status_t clip_region_to_shorts(
const BRegion * input,
int16 * data,
int max_count,
int * out_count);
uint32 _reserved_buffer_producer_[14];
};
#endif /* _BUFFER_PRODUCER_H */
+139
View File
@@ -0,0 +1,139 @@
/*******************************************************************************
/
/ File: Controllable.h
/
/ Description: A BControllable is a BMediaNode with "tweakable" parameters/settings.
/
/ Copyright 1997-98, Be Incorporated, All Rights Reserved
/
*******************************************************************************/
#if !defined(_CONTROLLABLE_H)
#define _CONTROLLABLE_H
#include <MediaDefs.h>
#include <MediaNode.h>
class BParameterWeb;
class BControllable :
public virtual BMediaNode
{
protected:
/* Need this to force vtable */
virtual ~BControllable();
public:
/* BControllable might seem somewhat spartan. */
/* That is because control change requests and notifications */
/* typically come in/go out in B_MEDIA_PARAMETERS type buffers */
/* (and a BControllable thus also needs to be a BBufferConsumer */
/* and/or a BBufferProducer) */
/* The format of these buffers is: */
/* media_node(node), int32(count) */
/* repeat(count) { int64(when), int32(control_id), int32(value_size), <value> } */
BParameterWeb * Web();
bool LockParameterWeb();
void UnlockParameterWeb();
protected:
BControllable(); /* call SetParameterWeb() from your constructor */
status_t SetParameterWeb(
BParameterWeb * web);
virtual status_t HandleMessage(
int32 message,
const void * data,
size_t size);
/* Call when the actual control changes, NOT when the value changes. */
/* A typical case would be a CD with a Selector for Track when a new CD is inserted */
status_t BroadcastChangedParameter(
int32 id);
/* Call this function when a value change takes effect, and */
/* you want people who are interested to stay in sync with you. */
/* Don't call this too densely, though, or you will flood the system */
/* with messages. */
status_t BroadcastNewParameterValue(
bigtime_t when, // performance time
int32 id, // parameter ID
void * newValue,
size_t valueSize);
/* These are alternate methods of accomplishing the same thing as */
/* connecting to control information source/destinations would. */
virtual status_t GetParameterValue(
int32 id,
bigtime_t * last_change,
void * value,
size_t * ioSize) = 0;
virtual void SetParameterValue(
int32 id,
bigtime_t when,
const void * value,
size_t size) = 0;
/* The default implementation of StartControlPanel launches the add-on */
/* as an application (if the Node lives in an add-on). Thus, you can write your */
/* control panel as a "main()" in your add-on, and it'll automagically work! */
/* Your add-on needs to have multi-launch app flags for this to work right. */
/* The first argv argument to main() will be a string of the format "node=%d" */
/* with the node ID in question as "%d". */
virtual status_t StartControlPanel(
BMessenger * out_messenger);
/* Call this from your BufferReceived() for control information buffers */
/* if you implement BBufferConsumer for that format (recommended!) */
status_t ApplyParameterData(
const void * value,
size_t size);
/* If you want to generate control information for a set of controls, you */
/* can use this utility function. */
status_t MakeParameterData(
const int32 * controls,
int32 count,
void * buf,
size_t * ioSize);
private:
friend class BMediaNode;
BControllable( /* private unimplemented */
const BControllable & clone);
BControllable & operator=(
const BControllable & clone);
/* Mmmh, stuffing! */
virtual status_t _Reserved_Controllable_0(void *);
virtual status_t _Reserved_Controllable_1(void *);
virtual status_t _Reserved_Controllable_2(void *);
virtual status_t _Reserved_Controllable_3(void *);
virtual status_t _Reserved_Controllable_4(void *);
virtual status_t _Reserved_Controllable_5(void *);
virtual status_t _Reserved_Controllable_6(void *);
virtual status_t _Reserved_Controllable_7(void *);
virtual status_t _Reserved_Controllable_8(void *);
virtual status_t _Reserved_Controllable_9(void *);
virtual status_t _Reserved_Controllable_10(void *);
virtual status_t _Reserved_Controllable_11(void *);
virtual status_t _Reserved_Controllable_12(void *);
virtual status_t _Reserved_Controllable_13(void *);
virtual status_t _Reserved_Controllable_14(void *);
virtual status_t _Reserved_Controllable_15(void *);
BParameterWeb * _mWeb;
sem_id _m_webSem;
int32 _m_webBen;
uint32 _reserved_controllable_[14];
};
#endif /* _CONTROLLABLE_H */
+91
View File
@@ -0,0 +1,91 @@
/*******************************************************************************
/
/ File: FileInterface.h
/
/ Description: A BFileInterface is something which can read and/or write files for the
/ use of other Media Kit participants.
/
/ Copyright 1997-98, Be Incorporated, All Rights Reserved
/
*******************************************************************************/
#if !defined(_FILE_INTERFACE_H)
#define _FILE_INTERFACE_H
#include <MediaDefs.h>
#include <MediaNode.h>
class BFileInterface :
public virtual BMediaNode
{
protected:
virtual ~BFileInterface(); /* force vtable */
public:
/* look, no hands! */
protected:
BFileInterface();
virtual status_t HandleMessage(
int32 message,
const void * data,
size_t size);
virtual status_t GetNextFileFormat(
int32 * cookie,
media_file_format * out_format) = 0;
virtual void DisposeFileFormatCookie(
int32 cookie) = 0;
virtual status_t GetDuration(
bigtime_t * out_time) = 0;
virtual status_t SniffRef(
const entry_ref & file,
char * out_mime_type, /* 256 bytes */
float * out_quality) = 0;
virtual status_t SetRef(
const entry_ref & file,
bool create,
bigtime_t * out_time) = 0;
virtual status_t GetRef(
entry_ref * out_ref,
char * out_mime_type) = 0;
private:
friend class BMediaNode;
BFileInterface( /* private unimplemented */
const BFileInterface & clone);
BFileInterface & operator=(
const BFileInterface & clone);
/* Mmmh, stuffing! */
virtual status_t _Reserved_FileInterface_0(void *);
virtual status_t _Reserved_FileInterface_1(void *);
virtual status_t _Reserved_FileInterface_2(void *);
virtual status_t _Reserved_FileInterface_3(void *);
virtual status_t _Reserved_FileInterface_4(void *);
virtual status_t _Reserved_FileInterface_5(void *);
virtual status_t _Reserved_FileInterface_6(void *);
virtual status_t _Reserved_FileInterface_7(void *);
virtual status_t _Reserved_FileInterface_8(void *);
virtual status_t _Reserved_FileInterface_9(void *);
virtual status_t _Reserved_FileInterface_10(void *);
virtual status_t _Reserved_FileInterface_11(void *);
virtual status_t _Reserved_FileInterface_12(void *);
virtual status_t _Reserved_FileInterface_13(void *);
virtual status_t _Reserved_FileInterface_14(void *);
virtual status_t _Reserved_FileInterface_15(void *);
uint32 _reserved_file_interface_[16];
};
#endif /* _FILE_INTERFACE_H */
+174
View File
@@ -0,0 +1,174 @@
/*******************************************************************************
/
/ File: MediaAddOn.h
/
/ Description: A BMediaAddOn is created by Media Kit add-ons to instantiate and
/ handle "latent" Nodes.
/
/ Copyright 1997-98, Be Incorporated, All Rights Reserved
/
*******************************************************************************/
#if !defined(_MEDIA_ADD_ON_H)
#define _MEDIA_ADD_ON_H
#include <image.h>
#include <MediaDefs.h>
#include <Flattenable.h>
struct dormant_node_info {
dormant_node_info();
~dormant_node_info();
media_addon_id addon;
int32 flavor_id;
char name[B_MEDIA_NAME_LENGTH];
private:
char reserved[128];
};
enum
{ // flavor_flags
B_FLAVOR_IS_GLOBAL = 0x100000L, // force in media_addon_server, only one instance
B_FLAVOR_IS_LOCAL = 0x200000L // force in loading app, many instances
// if none is set, could go either way
};
struct flavor_info {
char * name;
char * info;
uint64 kinds; /* node_kind */
uint32 flavor_flags;
int32 internal_id; /* For BMediaAddOn internal use */
int32 possible_count; /* 0 for "any number" */
int32 in_format_count; /* for BufferConsumer kinds */
uint32 in_format_flags; /* set to 0 */
const media_format * in_formats;
int32 out_format_count; /* for BufferProducer kinds */
uint32 out_format_flags; /* set to 0 */
const media_format * out_formats;
uint32 _reserved_[16];
private:
flavor_info & operator=(const flavor_info & other);
};
struct dormant_flavor_info : public flavor_info, public BFlattenable {
dormant_flavor_info();
virtual ~dormant_flavor_info();
dormant_flavor_info(const dormant_flavor_info &);
dormant_flavor_info& operator=(const dormant_flavor_info &);
dormant_flavor_info& operator=(const flavor_info &);
dormant_node_info node_info;
void set_name(const char * in_name);
void set_info(const char * in_info);
void add_in_format(const media_format & in_format);
void add_out_format(const media_format & out_format);
virtual bool IsFixedSize() const;
virtual type_code TypeCode() const;
virtual ssize_t FlattenedSize() const;
virtual status_t Flatten(void *buffer, ssize_t size) const;
virtual status_t Unflatten(type_code c, const void *buf, ssize_t size);
};
/* a MediaAddOn is something which can manufacture MediaNodes */
class BMediaAddOn
{
public:
explicit BMediaAddOn(
image_id image);
virtual ~BMediaAddOn();
virtual status_t InitCheck(
const char ** out_failure_text);
virtual int32 CountFlavors();
virtual status_t GetFlavorAt(
int32 n,
const flavor_info ** out_info);
virtual BMediaNode * InstantiateNodeFor(
const flavor_info * info,
BMessage * config,
status_t * out_error);
virtual status_t GetConfigurationFor(
BMediaNode * your_node,
BMessage * into_message);
virtual bool WantsAutoStart();
virtual status_t AutoStart(
int in_count,
BMediaNode ** out_node,
int32 * out_internal_id,
bool * out_has_more);
/* only implement if you have a B_FILE_INTERFACE node */
virtual status_t SniffRef(
const entry_ref & file,
BMimeType * io_mime_type,
float * out_quality,
int32 * out_internal_id);
virtual status_t SniffType( // This is broken if you deal with producers
const BMimeType & type, // and consumers both. Use SniffTypeKind instead.
float * out_quality, // If you implement SniffTypeKind, this doesn't
int32 * out_internal_id); // get called.
virtual status_t GetFileFormatList(
int32 flavor_id, // for this node flavor (if it matters)
media_file_format * out_writable_formats, // don't write here if NULL
int32 in_write_items, // this many slots in out_writable_formats
int32 * out_write_items, // set this to actual # available, even if bigger than in count
media_file_format * out_readable_formats, // don't write here if NULL
int32 in_read_items, // this many slots in out_readable_formats
int32 * out_read_items, // set this to actual # available, even if bigger than in count
void * _reserved); // ignore until further notice
virtual status_t SniffTypeKind( // Like SniffType, but for the specific kind(s)
const BMimeType & type,
uint64 in_kinds,
float * out_quality,
int32 * out_internal_id,
void * _reserved);
image_id ImageID();
media_addon_id AddonID();
protected:
// Calling this will cause everyone to get notified, and also
// cause the server to re-scan your flavor info. It is thread safe.
status_t NotifyFlavorChange();
private:
BMediaAddOn(); /* private unimplemented */
BMediaAddOn(const BMediaAddOn & clone);
BMediaAddOn & operator=(const BMediaAddOn & clone);
/* Mmmh, stuffing! */
virtual status_t _Reserved_MediaAddOn_2(void *);
virtual status_t _Reserved_MediaAddOn_3(void *);
virtual status_t _Reserved_MediaAddOn_4(void *);
virtual status_t _Reserved_MediaAddOn_5(void *);
virtual status_t _Reserved_MediaAddOn_6(void *);
virtual status_t _Reserved_MediaAddOn_7(void *);
image_id _fImage;
media_addon_id _fAddon;
uint32 _reserved_media_add_on_[7];
};
#if BUILDING_MEDIA_ADDON
extern "C" _EXPORT BMediaAddOn * make_media_addon(image_id you);
#endif
#endif /* _MEDIA_ADD_ON_H */
+90
View File
@@ -0,0 +1,90 @@
#ifndef MEDIADECODER_H
#define MEDIADECODER_H
#include <MediaDefs.h>
#include <MediaFormats.h>
namespace BPrivate {
class Decoder;
}
class BMediaDecoder {
public:
BMediaDecoder();
BMediaDecoder(const media_format *in_format,
const void *info = NULL, size_t info_size = 0);
BMediaDecoder(const media_codec_info *mci);
virtual ~BMediaDecoder();
status_t InitCheck() const;
status_t SetTo(const media_format *in_format,
const void *info = NULL, size_t info_size = 0);
status_t SetTo(const media_codec_info *mci);
status_t SetInputFormat(const media_format *in_format,
const void *in_info = NULL, size_t in_size = 0);
status_t SetOutputFormat(media_format *output_format);
// Set output format to closest acceptable format, returns the
// format used.
status_t Decode(void *out_buffer, int64 *out_frameCount,
media_header *out_mh, media_decode_info *info);
status_t GetDecoderInfo(media_codec_info *out_info) const;
protected:
virtual status_t GetNextChunk(const void **chunkData, size_t *chunkLen,
media_header *mh) = 0;
private:
// unimplemented
BMediaDecoder(const BMediaDecoder &);
BMediaDecoder & operator=(const BMediaDecoder &);
static status_t next_chunk(void *classptr, void **chunkData, size_t *chunkLen, media_header *mh);
void ReleaseDecoder();
BPrivate::Decoder *fDecoder;
int32 fDecoderID;
status_t fInitStatus;
/* fbc data and virtuals */
uint32 _reserved_BMediaDecoder_[32];
virtual status_t _Reserved_BMediaDecoder_0(int32 arg, ...);
virtual status_t _Reserved_BMediaDecoder_1(int32 arg, ...);
virtual status_t _Reserved_BMediaDecoder_2(int32 arg, ...);
virtual status_t _Reserved_BMediaDecoder_3(int32 arg, ...);
virtual status_t _Reserved_BMediaDecoder_4(int32 arg, ...);
virtual status_t _Reserved_BMediaDecoder_5(int32 arg, ...);
virtual status_t _Reserved_BMediaDecoder_6(int32 arg, ...);
virtual status_t _Reserved_BMediaDecoder_7(int32 arg, ...);
virtual status_t _Reserved_BMediaDecoder_8(int32 arg, ...);
virtual status_t _Reserved_BMediaDecoder_9(int32 arg, ...);
virtual status_t _Reserved_BMediaDecoder_10(int32 arg, ...);
virtual status_t _Reserved_BMediaDecoder_11(int32 arg, ...);
virtual status_t _Reserved_BMediaDecoder_12(int32 arg, ...);
virtual status_t _Reserved_BMediaDecoder_13(int32 arg, ...);
virtual status_t _Reserved_BMediaDecoder_14(int32 arg, ...);
virtual status_t _Reserved_BMediaDecoder_15(int32 arg, ...);
};
class BMediaBufferDecoder : public BMediaDecoder {
public:
BMediaBufferDecoder();
BMediaBufferDecoder(const media_format *in_format,
const void *info = NULL, size_t info_size = 0);
BMediaBufferDecoder(const media_codec_info *mci);
status_t DecodeBuffer(const void *input_buffer, size_t input_size,
void *out_buffer, int64 *out_frameCount,
media_header *out_mh,
media_decode_info *info = NULL);
protected:
virtual status_t GetNextChunk(const void **chunkData, size_t *chunkLen,
media_header *mh);
const void *buffer;
int32 buffer_size;
};
#endif
+736
View File
@@ -0,0 +1,736 @@
/*******************************************************************************
/
/ File: MediaDefs.h
/
/ Description: Basic data types and defines for the Media Kit.
/
/ Copyright 1997-1999, Be Incorporated, All Rights Reserved
/
*******************************************************************************/
#if !defined(_MEDIA_DEFS_H)
#define _MEDIA_DEFS_H
#include <BeBuild.h>
#include <SupportDefs.h>
#include <OS.h>
#include <ByteOrder.h>
#if defined(__cplusplus)
#include <GraphicsDefs.h>
#include <Looper.h>
#endif
#define B_MEDIA_NAME_LENGTH 64
enum { /* maybe migrate these into Errors.h */
B_MEDIA_SYSTEM_FAILURE = (int)B_MEDIA_ERROR_BASE+0x100, /* 80004100 */
B_MEDIA_BAD_NODE,
B_MEDIA_NODE_BUSY,
B_MEDIA_BAD_FORMAT,
B_MEDIA_BAD_BUFFER,
B_MEDIA_TOO_MANY_NODES,
B_MEDIA_TOO_MANY_BUFFERS,
B_MEDIA_NODE_ALREADY_EXISTS,
B_MEDIA_BUFFER_ALREADY_EXISTS,
B_MEDIA_CANNOT_SEEK,
B_MEDIA_CANNOT_CHANGE_RUN_MODE,
B_MEDIA_APP_ALREADY_REGISTERED,
B_MEDIA_APP_NOT_REGISTERED,
B_MEDIA_CANNOT_RECLAIM_BUFFERS,
B_MEDIA_BUFFERS_NOT_RECLAIMED,
B_MEDIA_TIME_SOURCE_STOPPED,
B_MEDIA_TIME_SOURCE_BUSY, /* 80004110 */
B_MEDIA_BAD_SOURCE,
B_MEDIA_BAD_DESTINATION,
B_MEDIA_ALREADY_CONNECTED,
B_MEDIA_NOT_CONNECTED,
B_MEDIA_BAD_CLIP_FORMAT,
B_MEDIA_ADDON_FAILED,
B_MEDIA_ADDON_DISABLED,
B_MEDIA_CHANGE_IN_PROGRESS,
B_MEDIA_STALE_CHANGE_COUNT,
B_MEDIA_ADDON_RESTRICTED,
B_MEDIA_NO_HANDLER,
B_MEDIA_DUPLICATE_FORMAT,
B_MEDIA_REALTIME_DISABLED,
B_MEDIA_REALTIME_UNAVAILABLE
};
/* Notification message 'what's */
enum {
// Note that BMediaNode::node_error also belongs in here! */
B_MEDIA_WILDCARD = 'TRWC', /* used to match any notification in Start/StopWatching */
B_MEDIA_NODE_CREATED = 'TRIA', /* "media_node_id" (multiple items) */
B_MEDIA_NODE_DELETED, /* "media_node_id" (multiple items) */
B_MEDIA_CONNECTION_MADE, /* "output", "input", "format" */
B_MEDIA_CONNECTION_BROKEN, /* "source", "destination" */
B_MEDIA_BUFFER_CREATED, /* "clone_info" -- handled by BMediaRoster */
B_MEDIA_BUFFER_DELETED, /* "media_buffer_id" -- handled by BMediaRoster */
B_MEDIA_TRANSPORT_STATE, /* "state", "location", "realtime" */
B_MEDIA_PARAMETER_CHANGED, /* N "node", "parameter" */
B_MEDIA_FORMAT_CHANGED, /* N "source", "destination", "format" */
B_MEDIA_WEB_CHANGED, /* N "node" */
B_MEDIA_DEFAULT_CHANGED, /* "default", "node" -- handled by BMediaRoster */
B_MEDIA_NEW_PARAMETER_VALUE, /* N "node", "parameter", "when", "value" */
B_MEDIA_NODE_STOPPED, /* N "node", "when" */
B_MEDIA_FLAVORS_CHANGED /* "be:addon_id", "be:new_count", "be:gone_count" */
};
enum media_type {
B_MEDIA_NO_TYPE = -1,
B_MEDIA_UNKNOWN_TYPE = 0,
B_MEDIA_RAW_AUDIO = 1, /* uncompressed raw_audio -- linear relationship bytes <-> samples */
B_MEDIA_RAW_VIDEO, /* uncompressed raw_video -- linear relationship bytes <-> pixels */
B_MEDIA_VBL, /* raw data from VBL area, 1600/line */
B_MEDIA_TIMECODE, /* data format TBD */
B_MEDIA_MIDI,
B_MEDIA_TEXT, /* typically closed captioning */
B_MEDIA_HTML,
B_MEDIA_MULTISTREAM, /* AVI, etc */
B_MEDIA_PARAMETERS, /* BControllable change data */
B_MEDIA_ENCODED_AUDIO, /* dts, AC3, ... */
B_MEDIA_ENCODED_VIDEO, /* Indeo, MPEG, ... */
B_MEDIA_PRIVATE = 90000, /* Don't touch! */
B_MEDIA_FIRST_USER_TYPE = 100000 /* Use something bigger than this for */
/* experimentation with your own media forms */
};
enum node_kind {
B_BUFFER_PRODUCER = 0x1,
B_BUFFER_CONSUMER = 0x2,
B_TIME_SOURCE = 0x4,
B_CONTROLLABLE = 0x8,
B_FILE_INTERFACE = 0x10,
B_ENTITY_INTERFACE = 0x20,
/* Set these flags for nodes that are suitable as default entities */
B_PHYSICAL_INPUT = 0x10000,
B_PHYSICAL_OUTPUT = 0x20000,
B_SYSTEM_MIXER = 0x40000
};
enum video_orientation { /* for orientation, which pixel is first and how do we scan each "line"? */
B_VIDEO_TOP_LEFT_RIGHT = 1, /* This is the typical progressive scan format */
B_VIDEO_BOTTOM_LEFT_RIGHT /* This is how BMP and TGA might scan */
};
enum media_flags /* data */
{
B_MEDIA_FLAGS_VERSION = 1, /* uint32, bigger for newer */
B_MEDIA_FLAGS_PRIVATE = 0x40000000 /* private to Be */
};
enum media_producer_status { /* for producer status */
B_DATA_NOT_AVAILABLE = 1,
B_DATA_AVAILABLE = 2,
B_PRODUCER_STOPPED = 3
};
// realtime flags
enum media_realtime_flags {
B_MEDIA_REALTIME_ALLOCATOR = 0x1,
B_MEDIA_REALTIME_AUDIO = 0x2,
B_MEDIA_REALTIME_VIDEO = 0x4,
B_MEDIA_REALTIME_ANYKIND = 0xffff
};
enum media_frame_flags {
B_MEDIA_KEY_FRAME = 0x1
};
#define B_MEDIA_ANY_QUALITY 0.0f
#define B_MEDIA_LOW_QUALITY 0.1f
#define B_MEDIA_MEDIUM_QUALITY 0.5f
#define B_MEDIA_HIGH_QUALITY 1.0f
#if !defined(_MULTI_AUDIO_H) /* #define in protocol header */
enum media_multi_channels {
B_CHANNEL_LEFT = 0x1,
B_CHANNEL_RIGHT = 0x2,
B_CHANNEL_CENTER = 0x4, /* 5.1+ or fake surround */
B_CHANNEL_SUB = 0x8, /* 5.1+ */
B_CHANNEL_REARLEFT = 0x10, /* quad surround or 5.1+ */
B_CHANNEL_REARRIGHT = 0x20, /* quad surround or 5.1+ */
B_CHANNEL_FRONT_LEFT_CENTER = 0x40,
B_CHANNEL_FRONT_RIGHT_CENTER = 0x80,
B_CHANNEL_BACK_CENTER = 0x100, /* 6.1 or fake surround */
B_CHANNEL_SIDE_LEFT = 0x200,
B_CHANNEL_SIDE_RIGHT = 0x400,
B_CHANNEL_TOP_CENTER = 0x800,
B_CHANNEL_TOP_FRONT_LEFT = 0x1000,
B_CHANNEL_TOP_FRONT_CENTER = 0x2000,
B_CHANNEL_TOP_FRONT_RIGHT = 0x4000,
B_CHANNEL_TOP_BACK_LEFT = 0x8000,
B_CHANNEL_TOP_BACK_CENTER = 0x10000,
B_CHANNEL_TOP_BACK_RIGHT = 0x20000
};
enum media_multi_matrix {
B_MATRIX_PROLOGIC_LR = 0x1,
B_MATRIX_AMBISONIC_WXYZ = 0x4
};
#endif
typedef int32 media_node_id;
typedef int32 media_buffer_id;
typedef int32 media_addon_id;
#if defined(__cplusplus)
struct media_destination {
media_destination(port_id, int32);
media_destination(const media_destination & clone);
media_destination & operator=(const media_destination & clone);
media_destination();
~media_destination();
port_id port; /* can be different from media_node.port */
int32 id;
static media_destination null;
private:
uint32 _reserved_media_destination_[2];
};
struct media_source {
media_source(port_id, int32);
media_source(const media_source & clone);
media_source & operator=(const media_source & clone);
media_source();
~media_source();
port_id port; /* must be the same as media_node.port for owner */
int32 id;
static media_source null;
private:
uint32 _reserved_media_source_[2];
};
_IMPEXP_MEDIA bool operator==(const media_destination & a, const media_destination & b);
_IMPEXP_MEDIA bool operator!=(const media_destination & a, const media_destination & b);
_IMPEXP_MEDIA bool operator<(const media_destination & a, const media_destination & b);
_IMPEXP_MEDIA bool operator==(const media_source & a, const media_source & b);
_IMPEXP_MEDIA bool operator!=(const media_source & a, const media_source & b);
_IMPEXP_MEDIA bool operator<(const media_source & a, const media_source & b);
_IMPEXP_MEDIA bool operator==(const media_node & a, const media_node & b);
_IMPEXP_MEDIA bool operator!=(const media_node & a, const media_node & b);
_IMPEXP_MEDIA bool operator<(const media_node & a, const media_node & b);
/* Buffers are low-level constructs identified by an ID. */
/* Buffers consist of the actual data area, plus a 64-byte */
/* header area that is different for each type. */
/* Buffers contain typed data. Type is not part of the */
/* buffer header; it's negotiated out-of-bounds by nodes. */
enum {
B_MEDIA_BIG_ENDIAN = 1,
B_MEDIA_LITTLE_ENDIAN = 2,
#if B_HOST_IS_BENDIAN
B_MEDIA_HOST_ENDIAN = B_MEDIA_BIG_ENDIAN
#else
B_MEDIA_HOST_ENDIAN = B_MEDIA_LITTLE_ENDIAN
#endif
};
struct media_multi_audio_format;
struct media_raw_audio_format {
enum { // for "format"
B_AUDIO_FLOAT = 0x24, // 0 == mid, -1.0 == bottom, 1.0 == top (the preferred format for non-game audio)
B_AUDIO_INT = 0x4, // 0 == mid, 0x80000001 == bottom, 0x7fffffff == top (all >16-bit formats, left-adjusted)
B_AUDIO_SHORT = 0x2, // 0 == mid, -32767 == bottom, +32767 == top
B_AUDIO_UCHAR = 0x11, // 128 == mid, 1 == bottom, 255 == top (discouraged but supported format)
B_AUDIO_CHAR = 0x1, // 0 == mid, -127 == bottom, +127 == top (not officially supported format)
B_AUDIO_SIZE_MASK = 0xf
}; // we guarantee that (format&0xf) == sizeof(sample) for raw formats
float frame_rate;
uint32 channel_count; // 1 or 2, mostly
uint32 format; // for compressed formats, go to media_encoded_audio_format
uint32 byte_order; // 2 for little endian (B_MEDIA_LITTLE_ENDIAN), 1 for big endian (B_MEDIA_BIG_ENDIAN)
size_t buffer_size; // size of each buffer
static media_multi_audio_format wildcard;
};
struct media_audio_header {
// please put actual data at the end
int32 _reserved_[16]; // gotta have something
};
struct media_multi_audio_info {
uint32 channel_mask; // bitmask
int16 valid_bits; // if < 32, for B_AUDIO_INT
uint16 matrix_mask; // each of these bits may mean more than one channel
uint32 _reserved_b[3];
};
#if defined(__cplusplus)
struct media_multi_audio_format : public media_raw_audio_format, public media_multi_audio_info {
static media_multi_audio_format wildcard;
};
#else
struct media_multi_audio_format {
media_raw_audio_format raw;
media_multi_audio_info multi;
};
#endif
struct media_encoded_audio_format {
enum audio_encoding {
B_ANY
};
media_raw_audio_format output;
audio_encoding encoding;
float bit_rate; // BIT rate, not byte rate
size_t frame_size;
media_multi_audio_info multi_info;
uint32 _reserved_[3];
static media_encoded_audio_format wildcard;
};
struct media_encoded_audio_header {
// please put actual data at the end
int32 _reserved_0[14]; // gotta have something
uint32 buffer_flags; // B_MEDIA_KEY_FRAME for key buffers (ADPCM etc)
uchar unused_mask; // mask of unused bits for the last byte of data
uchar _reserved_2[3];
};
enum media_display_flags {
B_F1_DOMINANT = 0x1, // The first buffer sent (temporally) will be an F1 field
B_F2_DOMINANT = 0x2, // The first buffer sent (temporally) will be an F2 field
B_TOP_SCANLINE_F1 = 0x4, // The topmost scanline of the output buffer belongs to F1
B_TOP_SCANLINE_F2 = 0x8 // The topmost scanline of the output buffer belongs to F2
};
struct media_video_display_info {
color_space format;
uint32 line_width;
uint32 line_count; // total of all interlace fields
uint32 bytes_per_row; // bytes_per_row is in format, not header, because it's part of SetBuffers
uint32 pixel_offset; // (in pixels) ... These are offsets from the start of the buffer ...
uint32 line_offset; // (in lines) ... to the start of the field. Think "buffer == framebuffer" ...
// ... when the window displaying the active field moves on screen.
uint32 flags;
uint32 _reserved_[3];
static media_video_display_info wildcard;
};
struct media_raw_video_format {
float field_rate;
uint32 interlace; // how many fields per frame -- 1 means progressive (non-interlaced)
uint32 first_active; // 0, typically (wildcard, or "don't care")
uint32 last_active; // line_count-1, if first_active is 0.
uint32 orientation; // B_VIDEO_TOP_LEFT_RIGHT is preferred
// PIXEL aspect ratio; not active area aspect ratio...
uint16 pixel_width_aspect; // 1:1 has 1 here, 4:3 has 4 here
uint16 pixel_height_aspect; // 1:1 has 1 here, 4:3 has 3 here
media_video_display_info display;
static media_raw_video_format wildcard;
};
struct media_video_header {
uint32 _reserved_[12]; // at the top to push used data to the end
float field_gamma;
uint32 field_sequence; // sequence since start of capture -- may roll over if machine is on for a LONG time
uint16 field_number; // 0 .. {interlace-1}; F1 == 0 ("odd"), F2 == 1 ("even")
uint16 pulldown_number; // 0..2 for pulldown duplicated sequence
uint16 first_active_line; // the NTSC/PAL line number (1-based) of the first line in this field
uint16 line_count; // number of active lines in buffer
};
struct media_encoded_video_format {
enum video_encoding {
B_ANY
};
media_raw_video_format output; // set unknowns to wildcard
float avg_bit_rate;
float max_bit_rate;
video_encoding encoding;
size_t frame_size;
int16 forward_history; // maximum forward memory required by algorithm
int16 backward_history; // maximum backward memory required by algorithm
uint32 _reserved_[3]; // can't grow more than this
static media_encoded_video_format wildcard;
};
struct media_encoded_video_header {
/* please put actual data at the end */
int32 _reserved_1[9]; // gotta have something...
uint32 field_flags; // B_MEDIA_KEY_FRAME
int16 forward_history; // forward memory required by this buffer (0 for key frames)
int16 backward_history; // backward memory required by this buffer (0 for key frames)
uchar unused_mask; // mask of unused bits for the last byte of data
uchar _reserved_2[3];
float field_gamma;
uint32 field_sequence; // sequence since start of capture
uint16 field_number; // 0 .. {interlace-1}; F1 == 0, F2 == 1
uint16 pulldown_number; // 0..2 for pulldown duplicated sequence
uint16 first_active_line; // 0 or 1, typically, but could be 10 or 11 for full-NTSC formats
uint16 line_count; // number of actual lines in buffer
};
struct media_multistream_format {
enum {
B_ANY = 0,
B_VID = 1, // raw raw_video/raw_audio buffers
B_AVI,
B_MPEG1,
B_MPEG2,
B_QUICKTIME,
B_PRIVATE = 90000,
B_FIRST_USER_TYPE = 100000 // user formats >= 100000
};
float avg_bit_rate; // 8 * byte rate, on average
float max_bit_rate; // 8 * byte rate, tops
uint32 avg_chunk_size; // == max_chunk_size for fixed-size chunks
uint32 max_chunk_size; // max buffer size
enum {
B_HEADER_HAS_FLAGS = 0x1, // are flags important?
B_CLEAN_BUFFERS = 0x2, // each buffer represents an integral number of "frames"
B_HOMOGENOUS_BUFFERS = 0x4 // a buffer has only one format in it
};
uint32 flags;
int32 format;
uint32 _reserved_[2];
struct vid_info {
float frame_rate;
uint16 width;
uint16 height;
color_space space;
float sampling_rate;
uint32 sample_format;
uint16 byte_order;
uint16 channel_count;
};
struct avi_info {
uint32 us_per_frame;
uint16 width;
uint16 height;
uint16 _reserved_;
uint16 type_count;
media_type types[5];
};
union {
vid_info vid;
avi_info avi;
} u;
static media_multistream_format wildcard;
};
struct media_multistream_header {
uint32 _reserved_[14];
uchar unused_mask; // mask of unused bits for the last byte of data
uchar _reserved_2[3];
enum {
B_MASTER_HEADER = 0x1, // for master stream header data in buffer
B_SUBSTREAM_HEADER = 0x2, // for sub-stream header data in buffer
B_COMPLETE_BUFFER = 0x4 // data is an integral number of "frames"
};
uint32 flags;
};
extern const type_code B_CODEC_TYPE_INFO;
enum media_format_flags {
B_MEDIA_RETAINED_DATA = 0x1,
B_MEDIA_MULTIPLE_BUFFERS = 0x2,
B_MEDIA_CONTIGUOUS_BUFFER = 0x4,
B_MEDIA_LINEAR_UPDATES = 0x8,
B_MEDIA_MAUI_UNDEFINED_FLAGS = ~0xf /* always deny these */
};
/* typically, a field of 0 means "anything" or "wildcard" */
struct media_format { /* no more than 192 bytes */
media_type type;
type_code user_data_type;
uchar user_data[48];
uint32 _reserved_[3];
uint16 require_flags; // media_format_flags
uint16 deny_flags; // media_format_flags
private:
void * meta_data;
int32 meta_data_size;
area_id meta_data_area;
area_id use_area;
team_id team;
void * thisPtr;
public:
union {
media_multi_audio_format raw_audio;
media_raw_video_format raw_video;
media_multistream_format multistream;
media_encoded_audio_format encoded_audio;
media_encoded_video_format encoded_video;
char _reserved_[96]; // pad to 96 bytes
} u;
bool IsVideo() const { return (type==B_MEDIA_ENCODED_VIDEO)||(type==B_MEDIA_RAW_VIDEO); };
uint32 Width() const { return (type==B_MEDIA_ENCODED_VIDEO)?u.encoded_video.output.display.line_width:u.raw_video.display.line_width; };
uint32 Height() const { return (type==B_MEDIA_ENCODED_VIDEO)?u.encoded_video.output.display.line_count:u.raw_video.display.line_count; };
color_space ColorSpace() const { return (type==B_MEDIA_ENCODED_VIDEO)?u.encoded_video.output.display.format:u.raw_video.display.format; };
uint32 & Width() { return (type==B_MEDIA_ENCODED_VIDEO)?u.encoded_video.output.display.line_width:u.raw_video.display.line_width; };
uint32 & Height() { return (type==B_MEDIA_ENCODED_VIDEO)?u.encoded_video.output.display.line_count:u.raw_video.display.line_count; };
color_space & ColorSpace() { return (type==B_MEDIA_ENCODED_VIDEO)?u.encoded_video.output.display.format:u.raw_video.display.format; };
bool IsAudio() const { return (type==B_MEDIA_ENCODED_AUDIO)||(type==B_MEDIA_RAW_AUDIO); };
uint32 AudioFormat() const { return (type==B_MEDIA_ENCODED_AUDIO)?u.encoded_audio.output.format:u.raw_audio.format; };
uint32 & AudioFormat() { return (type==B_MEDIA_ENCODED_AUDIO)?u.encoded_audio.output.format:u.raw_audio.format; };
uint32 Encoding() const { return (type==B_MEDIA_ENCODED_VIDEO)?u.encoded_video.encoding:(type==B_MEDIA_ENCODED_AUDIO)?u.encoded_audio.encoding:(type==B_MEDIA_MULTISTREAM)?u.multistream.format:0UL; }
bool Matches(const media_format *otherFormat) const;
void SpecializeTo(const media_format *otherFormat);
status_t SetMetaData(const void *data, size_t size);
const void * MetaData() const;
int32 MetaDataSize() const;
media_format();
media_format(const media_format &other);
~media_format();
media_format & operator=(const media_format & clone);
};
_IMPEXP_MEDIA bool operator==(const media_raw_audio_format & a, const media_raw_audio_format & b);
_IMPEXP_MEDIA bool operator==(const media_multi_audio_info & a, const media_multi_audio_info & b);
_IMPEXP_MEDIA bool operator==(const media_multi_audio_format & a, const media_multi_audio_format & b);
_IMPEXP_MEDIA bool operator==(const media_encoded_audio_format & a, const media_encoded_audio_format & b);
_IMPEXP_MEDIA bool operator==(const media_video_display_info & a, const media_video_display_info & b);
_IMPEXP_MEDIA bool operator==(const media_raw_video_format & a, const media_raw_video_format & b);
_IMPEXP_MEDIA bool operator==(const media_encoded_video_format & a, const media_encoded_video_format & b);
_IMPEXP_MEDIA bool operator==(const media_multistream_format::vid_info & a, const media_multistream_format::vid_info & b);
_IMPEXP_MEDIA bool operator==(const media_multistream_format::avi_info & a, const media_multistream_format::avi_info & b);
_IMPEXP_MEDIA bool operator==(const media_multistream_format & a, const media_multistream_format & b);
_IMPEXP_MEDIA bool operator==(const media_format & a, const media_format & b);
/* return true if a and b are compatible (accounting for wildcards) */
_IMPEXP_MEDIA bool format_is_compatible(const media_format & a, const media_format & b); /* a is the format you want to feed to something accepting b */
_IMPEXP_MEDIA bool string_for_format(const media_format & f, char * buf, size_t size);
struct media_seek_tag {
char data[16];
};
struct media_header_time_code {
int8 type; // See TimeCode.h; don't use the "DEFAULT" value
int8 _reserved;
int8 hours;
int8 minutes;
int8 seconds;
int8 frames;
int16 subframes; // -1 if not available
};
struct media_header { // Broadcast() fills in fields marked with "//+"
media_type type; // what kind of data (for union)
media_buffer_id buffer; //+ what buffer does this header go with?
int32 destination; //+ what 'socket' is this intended for?
media_node_id time_source; // node that encoded start_time
uint32 _deprecated_; // used to be change_tag
uint32 size_used; // size within buffer that is used
bigtime_t start_time; // performance time
area_id owner; //+ buffer owner info area
enum {
B_SEEK_TAG = 'TRST', // user data type of the codec seek
// protocol. size of seek tag is 16 bytes
B_TIME_CODE = 'TRTC' // user data is media_header_time_code
};
type_code user_data_type;
uchar user_data[64]; // user_data_type indicates what this is
uint32 _reserved_[2];
off_t file_pos; // where in a file this data came from
size_t orig_size; // and how big it was. if unused, zero out
uint32 data_offset; // offset within buffer (already reflected in Data())
union {
media_audio_header raw_audio;
media_video_header raw_video;
media_multistream_header multistream;
media_encoded_audio_header encoded_audio;
media_encoded_video_header encoded_video;
char _reserved_[64]; // pad to 64 bytes
} u;
};
struct media_file_format_id {
ino_t node;
dev_t device;
uint32 internal_id;
};
_IMPEXP_MEDIA bool operator==(const media_file_format_id & a, const media_file_format_id & b);
_IMPEXP_MEDIA bool operator<(const media_file_format_id & a, const media_file_format_id & b);
typedef enum {
B_ANY_FORMAT_FAMILY = 0,
B_BEOS_FORMAT_FAMILY = 1,
B_QUICKTIME_FORMAT_FAMILY = 2, /* QuickTime is a registered trademark of Apple Computer */
B_AVI_FORMAT_FAMILY = 3,
B_ASF_FORMAT_FAMILY = 4,
B_MPEG_FORMAT_FAMILY = 5,
B_WAV_FORMAT_FAMILY = 6,
B_AIFF_FORMAT_FAMILY = 7,
B_AVR_FORMAT_FAMILY = 8,
B_MISC_FORMAT_FAMILY = 99999
} media_format_family;
struct media_file_format {
enum { /* flags */
B_READABLE = 0x1,
B_WRITABLE = 0x2,
B_PERFECTLY_SEEKABLE = 0x4,
B_IMPERFECTLY_SEEKABLE = 0x8,
B_KNOWS_RAW_VIDEO = 0x10,
B_KNOWS_RAW_AUDIO = 0x20,
B_KNOWS_MIDI = 0x40,
B_KNOWS_ENCODED_VIDEO = 0x80,
B_KNOWS_ENCODED_AUDIO = 0x100,
B_KNOWS_OTHER = 0x1000000, /* clipping, text, control, ... */
B_KNOWS_ANYTHING = 0x2000000
};
uint32 capabilities; // can this format support audio, video, etc
media_file_format_id id; // opaque id used to construct a BMediaFile
media_format_family family; // one of the family enums
int32 version; // 100 for 1.0
uint32 _reserved_[25];
char mime_type[64]; // eg: "video/quicktime", "audio/aiff", etc
char pretty_name[64]; // eg: "QuickTime File Format"
char short_name[32]; // eg: "quicktime", "avi", "mpeg"
char file_extension[8]; // eg: "mov", "avi", "mpg"
char reserved[88];
};
//
// Use this function iterate through available file format writers
//
status_t get_next_file_format(int32 *cookie, media_file_format *mfi);
/* This struct is guaranteed to be large enough for any message your service */
/* thread will get for any media_node -- 16k is an upper-bound size limit. */
/* In your thread, read_port() into this struct, and call HandleMessage() on it. */
const size_t B_MEDIA_MESSAGE_SIZE = 16384;
_IMPEXP_MEDIA extern const char * B_MEDIA_SERVER_SIGNATURE;
class media_node; /* found in MediaNode.h */
struct media_input;
struct media_output;
struct live_node_info;
struct dormant_node_info;
struct buffer_clone_info;
// If you for some reason need to get rid of the media_server (and friends)
// use these functions, rather than sending messages yourself.
// The callback will be called for various stages of the process, with 100 meaning completely done
// The callback should always return TRUE for the time being.
status_t shutdown_media_server(bigtime_t timeout = B_INFINITE_TIMEOUT, bool (*progress)(int stage, const char * message, void * cookie) = NULL, void * cookie = NULL);
status_t launch_media_server(uint32 flags = 0);
// Given an image_id, prepare that image_id for realtime media
// If the kind of media indicated by "flags" is not enabled for real-time,
// B_MEDIA_REALTIME_DISABLED is returned.
// If there are not enough system resources to enable real-time performance,
// B_MEDIA_REALTIME_UNAVAILABLE is returned.
status_t media_realtime_init_image(image_id image, uint32 flags);
// Given a thread ID, and an optional indication of what the thread is
// doing in "flags", prepare the thread for real-time media performance.
// Currently, this means locking the thread stack, up to size_used bytes,
// or all of it if 0 is passed. Typically, you will not be using all
// 256 kB of the stack, so you should pass some smaller value you determine
// from profiling the thread; typically in the 32-64kB range.
// Return values are the same as for media_prepare_realtime_image().
status_t media_realtime_init_thread(thread_id thread, size_t stack_used, uint32 flags);
// A teeny bit of legacy preserved for BSoundFile from R3.
// These came from the old MediaDefs.h; don't use them
// unless you get them from BSoundFile.
/* values for byte_ordering */
enum { B_BIG_ENDIAN, B_LITTLE_ENDIAN };
/* values for sample_format */
enum {
B_UNDEFINED_SAMPLES,
B_LINEAR_SAMPLES,
B_FLOAT_SAMPLES,
B_MULAW_SAMPLES
};
/* for encoders and file writers */
struct media_encode_info {
uint32 flags; /* B_MEDIA_KEY_FRAME, set before every use */
int32 used_data_size; /* data size used by other tracks */
/* add output size used by this encoder */
bigtime_t start_time; /* us from start of file */
bigtime_t time_to_encode; /* 0 - hurry up, B_INFINITE_TIMEOUT - don't care */
int32 _pad[22];
void *file_format_data; /* file format specific info */
size_t file_format_data_size;
void *codec_data; /* codec specific info */
size_t codec_data_size;
media_encode_info();
};
struct encode_parameters {
float quality; // 0.0-1.0 , 1.0 is high quality
int32 avg_field_size; // in bytes
int32 max_field_size; // in bytes
int32 _pad[27];
void *user_data; // codec specific info
size_t user_data_size;
};
struct media_decode_info {
bigtime_t time_to_decode; /* 0 - hurry up, B_INFINITE_TIMEOUT - don't care */
int32 _pad[26];
void *file_format_data; /* file format specific info */
size_t file_format_data_size;
void *codec_data; /* codec specific info */
size_t codec_data_size;
media_decode_info();
};
#endif // __cplusplus
#endif /* MEDIA_DEFS_H */
+91
View File
@@ -0,0 +1,91 @@
#ifndef MEDIAENCODER_H
#define MEDIAENCODER_H
#include <MediaDefs.h>
#include <MediaFormats.h>
namespace BPrivate {
class Encoder;
class _AddonManager;
}
class BMediaEncoder {
public:
BMediaEncoder();
BMediaEncoder(const media_format *output_format);
BMediaEncoder(const media_codec_info *mci);
virtual ~BMediaEncoder();
status_t InitCheck() const;
status_t SetTo(const media_format *output_format);
status_t SetTo(const media_codec_info *mci);
status_t SetFormat(media_format *input_format,
media_format *output_format,
media_file_format *mfi = NULL);
status_t Encode(const void *buffer, int64 frame_count,
media_encode_info *info);
status_t GetEncodeParameters(encode_parameters *parameters) const;
status_t SetEncodeParameters(encode_parameters *parameters);
protected:
virtual status_t WriteChunk(const void *chunk_data, size_t chunk_len,
media_encode_info *info) = 0;
virtual status_t AddTrackInfo(uint32 code, const char *data, size_t size);
private:
// unimplemented
BMediaEncoder(const BMediaEncoder &);
BMediaEncoder & operator=(const BMediaEncoder &);
static status_t write_chunk(void *classptr, const void *chunk_data,
size_t chunk_len, media_encode_info *info);
void Init();
void ReleaseEncoder();
BPrivate::_AddonManager *fEncoderMgr;
BPrivate::Encoder *fEncoder;
int32 fEncoderID;
bool fFormatValid;
bool fEncoderStarted;
status_t fInitStatus;
/* fbc data and virtuals */
uint32 _reserved_BMediaEncoder_[32];
virtual status_t _Reserved_BMediaEncoder_0(int32 arg, ...);
virtual status_t _Reserved_BMediaEncoder_1(int32 arg, ...);
virtual status_t _Reserved_BMediaEncoder_2(int32 arg, ...);
virtual status_t _Reserved_BMediaEncoder_3(int32 arg, ...);
virtual status_t _Reserved_BMediaEncoder_4(int32 arg, ...);
virtual status_t _Reserved_BMediaEncoder_5(int32 arg, ...);
virtual status_t _Reserved_BMediaEncoder_6(int32 arg, ...);
virtual status_t _Reserved_BMediaEncoder_7(int32 arg, ...);
virtual status_t _Reserved_BMediaEncoder_8(int32 arg, ...);
virtual status_t _Reserved_BMediaEncoder_9(int32 arg, ...);
virtual status_t _Reserved_BMediaEncoder_10(int32 arg, ...);
virtual status_t _Reserved_BMediaEncoder_11(int32 arg, ...);
virtual status_t _Reserved_BMediaEncoder_12(int32 arg, ...);
virtual status_t _Reserved_BMediaEncoder_13(int32 arg, ...);
virtual status_t _Reserved_BMediaEncoder_14(int32 arg, ...);
virtual status_t _Reserved_BMediaEncoder_15(int32 arg, ...);
};
class BMediaBufferEncoder: public BMediaEncoder {
public:
BMediaBufferEncoder();
BMediaBufferEncoder(const media_format *output_format);
BMediaBufferEncoder(const media_codec_info *mci);
status_t EncodeToBuffer(void *output_buffer, size_t *output_size,
const void *input_buffer, int64 frame_count,
media_encode_info *info);
protected:
virtual status_t WriteChunk(const void *chunk_data, size_t chunk_len,
media_encode_info *info);
void *fBuffer;
int32 fBufferSize;
};
#endif
+169
View File
@@ -0,0 +1,169 @@
/*******************************************************************************
/
/ File: MediaEventLooper.h
/
/ Description: BMediaEventLooper spawns a thread which calls WaitForMessage,
/ pushes BMediaNode messages onto its BTimedEventQueues.
/ informs you when it is time to handle an event.
/ Report your event latency, push other events onto the queue
/ and override HandleEvent to do your work.
/
/ Copyright 1999, Be Incorporated, All Rights Reserved
/
*******************************************************************************/
#if !defined(_MEDIA_EVENT_LOOPER_H)
#define _MEDIA_EVENT_LOOPER_H
#include <MediaNode.h>
#include <TimedEventQueue.h>
class BMediaEventLooper :
public virtual BMediaNode
{
protected:
enum run_state {
B_IN_DISTRESS = -1,
B_UNREGISTERED,
B_STOPPED,
B_STARTED,
B_QUITTING,
B_TERMINATED,
B_USER_RUN_STATES = 0x4000
};
protected:
/* this has to be on top rather than bottom to force a vtable in mwcc */
virtual ~BMediaEventLooper();
explicit BMediaEventLooper(uint32 apiVersion = B_BEOS_VERSION);
/* from BMediaNode */
protected:
virtual void NodeRegistered();
virtual void Start(bigtime_t performance_time);
virtual void Stop(bigtime_t performance_time, bool immediate);
virtual void Seek(bigtime_t media_time, bigtime_t performance_time);
virtual void TimeWarp(bigtime_t at_real_time, bigtime_t to_performance_time);
virtual status_t AddTimer(bigtime_t at_performance_time, int32 cookie);
virtual void SetRunMode(run_mode mode);
/* BMediaEventLooper Hook functions */
protected:
/* you must override to handle your events! */
/* you should not call HandleEvent directly */
virtual void HandleEvent( const media_timed_event *event,
bigtime_t lateness,
bool realTimeEvent = false) = 0;
/* override to clean up custom events you have added to your queue */
virtual void CleanUpEvent(const media_timed_event *event);
/* called from Offline mode to determine the current time of the node */
/* update your internal information whenever it changes */
virtual bigtime_t OfflineTime();
/* override only if you know what you are doing! */
/* otherwise much badness could occur */
/* the actual control loop function: */
/* waits for messages, Pops events off the queue and calls DispatchEvent */
virtual void ControlLoop();
thread_id ControlThread();
protected:
BTimedEventQueue * EventQueue();
BTimedEventQueue * RealTimeQueue();
int32 Priority() const;
int32 RunState() const;
bigtime_t EventLatency() const;
bigtime_t BufferDuration() const;
bigtime_t SchedulingLatency() const;
/* use the priority constants from OS.h */
/* or suggest_thread_priority from scheduler.h */
/* will clamp priorities to be inbetween 5 and 120 */
status_t SetPriority(int32 priority);
/* set the run state */
void SetRunState(run_state state);
/* clamps to 0 if latency < 0 */
void SetEventLatency(bigtime_t latency);
/* clamps to 0 if duration is < 0 */
void SetBufferDuration(bigtime_t duration);
/* set the offline time returned in OfflineTime */
void SetOfflineTime(bigtime_t offTime);
/* spawn and resume the thread - must be called from NodeRegistered */
void Run();
/* close down the thread - must be called from your destructor */
void Quit();
/* calls HandleEvent and does BMediaEventLooper event work */
void DispatchEvent( const media_timed_event *event,
bigtime_t lateness,
bool realTimeEvent = false);
private:
static int32 _ControlThreadStart(void *arg);
static void _CleanUpEntry(const media_timed_event *event, void *context);
void _DispatchCleanUp(const media_timed_event *event);
BTimedEventQueue fEventQueue;
BTimedEventQueue fRealTimeQueue;
thread_id fControlThread;
int32 fCurrentPriority;
int32 fSetPriority;
volatile int32 fRunState;
bigtime_t fEventLatency;
bigtime_t fSchedulingLatency;
bigtime_t fBufferDuration;
bigtime_t fOfflineTime;
uint32 fApiVersion;
private:
/* unimplemented for your protection */
BMediaEventLooper(const BMediaEventLooper&);
BMediaEventLooper& operator=(const BMediaEventLooper&);
protected:
virtual status_t DeleteHook(BMediaNode * node);
/* fragile base class stuffing */
private:
/* it must be thanksgiving!! lots of stuffing! */
virtual status_t _Reserved_BMediaEventLooper_0(int32 arg, ...);
virtual status_t _Reserved_BMediaEventLooper_1(int32 arg, ...);
virtual status_t _Reserved_BMediaEventLooper_2(int32 arg, ...);
virtual status_t _Reserved_BMediaEventLooper_3(int32 arg, ...);
virtual status_t _Reserved_BMediaEventLooper_4(int32 arg, ...);
virtual status_t _Reserved_BMediaEventLooper_5(int32 arg, ...);
virtual status_t _Reserved_BMediaEventLooper_6(int32 arg, ...);
virtual status_t _Reserved_BMediaEventLooper_7(int32 arg, ...);
virtual status_t _Reserved_BMediaEventLooper_8(int32 arg, ...);
virtual status_t _Reserved_BMediaEventLooper_9(int32 arg, ...);
virtual status_t _Reserved_BMediaEventLooper_10(int32 arg, ...);
virtual status_t _Reserved_BMediaEventLooper_11(int32 arg, ...);
virtual status_t _Reserved_BMediaEventLooper_12(int32 arg, ...);
virtual status_t _Reserved_BMediaEventLooper_13(int32 arg, ...);
virtual status_t _Reserved_BMediaEventLooper_14(int32 arg, ...);
virtual status_t _Reserved_BMediaEventLooper_15(int32 arg, ...);
virtual status_t _Reserved_BMediaEventLooper_16(int32 arg, ...);
virtual status_t _Reserved_BMediaEventLooper_17(int32 arg, ...);
virtual status_t _Reserved_BMediaEventLooper_18(int32 arg, ...);
virtual status_t _Reserved_BMediaEventLooper_19(int32 arg, ...);
virtual status_t _Reserved_BMediaEventLooper_20(int32 arg, ...);
virtual status_t _Reserved_BMediaEventLooper_21(int32 arg, ...);
virtual status_t _Reserved_BMediaEventLooper_22(int32 arg, ...);
virtual status_t _Reserved_BMediaEventLooper_23(int32 arg, ...);
/* turkey for weeks! */
bool _reserved_bool_[4];
uint32 _reserved_BMediaEventLooper_[12];
};
#endif
+207
View File
@@ -0,0 +1,207 @@
#ifndef _MEDIA_FILE_H
#define _MEDIA_FILE_H
#include <kernel/image.h>
#include <SupportDefs.h>
#include <StorageDefs.h>
#include <List.h>
#include <MediaDefs.h>
#include <MediaFormats.h>
namespace BPrivate {
class MediaExtractor;
class _IMPEXP_MEDIA MediaWriter;
class _AddonManager;
}
// forward declarations
class BMediaTrack;
class BParameterWeb;
class BView;
// flags for the BMediaFile constructor
enum {
B_MEDIA_FILE_REPLACE_MODE = 0x00000001,
B_MEDIA_FILE_NO_READ_AHEAD = 0x00000002,
B_MEDIA_FILE_UNBUFFERED = 0x00000006,
B_MEDIA_FILE_BIG_BUFFERS = 0x00000008
};
// BMediaFile represents a media file (AVI, Quicktime, MPEG, AIFF, WAV, etc)
//
// To read a file you construct a BMediaFile with an entry_ref, get the
// BMediaTracks out of it and use those to read the data.
//
// To write a file you construct a BMediaFile with an entry ref and an id as
// returned by get_next_file_format(). You then CreateTrack() to create
// various audio & video tracks. Once you're done creating tracks, call
// CommitHeader(), then write data to each track and call CloseFile() when
// you're done.
//
class BMediaFile {
public:
// these four constructors are used for read-only access
BMediaFile( const entry_ref *ref);
BMediaFile( BDataIO * source); // BFile is a BDataIO
BMediaFile( const entry_ref * ref,
int32 flags);
BMediaFile( BDataIO * source,
int32 flags); // BFile is a BDataIO
// these two constructors are for read-write access
BMediaFile(const entry_ref *ref, // these two are write-only
const media_file_format * mfi,
int32 flags=0);
BMediaFile(BDataIO *destination, // BFile is a BDataIO
const media_file_format * mfi,
int32 flags=0);
/* modified by Marcus Overhagen */
BMediaFile(const media_file_format * mfi,
int32 flags);
/* modified by Marcus Overhagen */
virtual ~BMediaFile();
status_t InitCheck() const;
// Get info about the underlying file format.
status_t GetFileFormatInfo(media_file_format *mfi) const;
//
// These functions are for read-only access to a media file.
// The data is read using the BMediaTrack object.
//
const char *Copyright(void) const;
int32 CountTracks() const;
// Can be called multiple times with the same index. You must call
// ReleaseTrack() when you're done with a track.
BMediaTrack *TrackAt(int32 index);
// Release the resource used by a given BMediaTrack object, to reduce
// the memory usage of your application. The specific 'track' object
// can no longer be used, but you can create another one by calling
// TrackAt() with the same track index.
status_t ReleaseTrack(BMediaTrack *track);
// A convenience.
status_t ReleaseAllTracks(void);
// Create and add a track to the media file
BMediaTrack *CreateTrack(media_format *mf, const media_codec_info *mci);
// Create and add a raw track to the media file (it has no encoder)
BMediaTrack *CreateTrack(media_format *mf);
// Lets you set the copyright info for the entire file
status_t AddCopyright(const char *data);
// Call this to add user-defined chunks to a file (if they're supported)
status_t AddChunk(int32 type, const void *data, size_t size);
// After you have added all the tracks you want, call this
status_t CommitHeader(void);
// After you have written all the data to the track objects, call this
status_t CloseFile(void);
// This is for controlling file format parameters
BParameterWeb *Web();
status_t GetParameterValue(int32 id, void *valu, size_t *size);
status_t SetParameterValue(int32 id, const void *valu, size_t size);
BView *GetParameterView();
// For the future...
virtual status_t Perform(int32 selector, void * data);
private:
BPrivate::MediaExtractor *fExtractor;
int32 _reserved_BMediaFile_was_fExtractorID;
int32 fTrackNum;
status_t fErr;
BPrivate::_AddonManager *fEncoderMgr;
BPrivate::_AddonManager *fWriterMgr;
BPrivate::MediaWriter *fWriter;
int32 fWriterID;
media_file_format fMFI;
bool fFileClosed;
bool _reserved_was_fUnused[3];
BList *fTrackList;
void Init();
void InitReader(BDataIO *source, int32 flags = 0);
void InitWriter(BDataIO *source, const media_file_format * mfi,
int32 flags);
BMediaFile();
BMediaFile(const BMediaFile&);
BMediaFile& operator=(const BMediaFile&);
BFile *fFile;
/* fbc data and virtuals */
uint32 _reserved_BMediaFile_[32];
virtual status_t _Reserved_BMediaFile_0(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_1(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_2(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_3(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_4(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_5(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_6(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_7(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_8(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_9(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_10(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_11(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_12(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_13(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_14(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_15(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_16(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_17(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_18(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_19(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_20(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_21(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_22(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_23(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_24(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_25(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_26(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_27(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_28(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_29(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_30(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_31(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_32(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_33(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_34(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_35(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_36(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_37(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_38(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_39(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_40(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_41(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_42(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_43(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_44(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_45(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_46(int32 arg, ...);
virtual status_t _Reserved_BMediaFile_47(int32 arg, ...);
};
#endif
+69
View File
@@ -0,0 +1,69 @@
/* MediaFiles.h */
/* Copyright 1998 Be Incorporated. All rights reserved. */
#if !defined(_MEDIA_FILES_H)
#define _MEDIA_FILES_H
#include <MediaDefs.h>
#include <List.h>
struct entry_ref;
#include <String.h>
class BMediaFiles {
public:
BMediaFiles();
virtual ~BMediaFiles();
virtual status_t RewindTypes();
virtual status_t GetNextType(
BString * out_type);
virtual status_t RewindRefs(
const char * type);
virtual status_t GetNextRef(
BString * out_type,
entry_ref * out_ref = NULL);
virtual status_t GetRefFor(
const char * type,
const char * item,
entry_ref * out_ref);
virtual status_t SetRefFor(
const char * type,
const char * item,
const entry_ref & ref);
virtual status_t RemoveRefFor( // This might better be called "ClearRefFor"
const char * type, // but it's too late now...
const char * item,
const entry_ref & ref);
static const char B_SOUNDS[]; /* for "types" */
virtual status_t RemoveItem( // new in 4.1, removes the whole item.
const char * type,
const char * item);
private:
status_t _Reserved_MediaFiles_0(void *, ...);
virtual status_t _Reserved_MediaFiles_1(void *, ...);
virtual status_t _Reserved_MediaFiles_2(void *, ...);
virtual status_t _Reserved_MediaFiles_3(void *, ...);
virtual status_t _Reserved_MediaFiles_4(void *, ...);
virtual status_t _Reserved_MediaFiles_5(void *, ...);
virtual status_t _Reserved_MediaFiles_6(void *, ...);
virtual status_t _Reserved_MediaFiles_7(void *, ...);
BList m_types;
int m_type_index;
BString m_cur_type;
BList m_items;
int m_item_index;
};
#endif /* _MEDIA_FILES_H */
+249
View File
@@ -0,0 +1,249 @@
/* MediaFormats.h */
/* Copyright 1998 Be Incorporated. All rights reserved. */
#if !defined(_MEDIA_TYPES_H)
#define _MEDIA_TYPES_H
#if defined(__cplusplus)
#include <MediaDefs.h>
#include <Messenger.h>
#include <List.h>
#include <Locker.h>
#endif
struct media_codec_info {
char pretty_name[96]; // eg: "SuperSqueeze Encoder by Foo Inc"
char short_name[32]; // eg: "supersqueeze"
int32 id; // opaque id passed to BMediaFile::CreateTrack
int32 sub_id;
int32 pad[63];
};
//
// Use this to iterate through the available encoders for a file format.
//
status_t get_next_encoder(int32 *cookie,
const media_file_format *mfi, // this comes from get_next_file_format()
const media_format *input_format, // this is the type of data given to the encoder
media_format *output_format, // this is the type of data encoder will output
media_codec_info *ei); // information about the encoder
status_t get_next_encoder(
int32 *cookie,
const media_file_format *mfi, // this comes from get_next_file_format()
// pass NULL if you don't care
const media_format *input_format, // this is the type of data given to the
// encoder, wildcards are accepted
const media_format *output_format, // this is the type of data encoder
// you want the encoder to output.
// Wildcards are accepted
media_codec_info *ei, // information about the encoder
media_format *accepted_input_format,// this is the type of data that the
// encoder will accept as input.
// Wildcards in input_format will be
// specialized here.
media_format *accepted_output_format// this is the type of data that the
// encoder will output.
// Wildcards in output_format will be
// specialized here.
);
status_t get_next_encoder(int32 *cookie, media_codec_info *ei);
enum media_file_accept_format_flags {
B_MEDIA_REJECT_WILDCARDS = 0x1
};
bool does_file_accept_format(const media_file_format *mfi,
media_format *format, uint32 flags = 0);
typedef struct {
uint8 data[16];
} GUID;
typedef struct {
int32 format;
} media_beos_description;
typedef struct {
uint32 codec;
uint32 vendor;
} media_quicktime_description;
typedef struct {
uint32 codec;
} media_avi_description;
typedef struct {
uint32 id;
} media_avr_description;
typedef struct {
GUID guid;
} media_asf_description;
enum mpeg_id {
B_MPEG_ANY = 0,
B_MPEG_1_AUDIO_LAYER_1 = 0x101,
B_MPEG_1_AUDIO_LAYER_2 = 0x102,
B_MPEG_1_AUDIO_LAYER_3 = 0x103, // "MP3"
B_MPEG_1_VIDEO = 0x111
};
typedef struct {
uint32 id;
} media_mpeg_description;
typedef struct {
uint32 codec;
} media_wav_description;
typedef struct {
uint32 codec;
} media_aiff_description;
typedef struct {
uint32 file_format;
uint32 codec;
} media_misc_description;
typedef struct _media_format_description {
#if defined(__cplusplus)
_media_format_description();
~_media_format_description();
_media_format_description(const _media_format_description & other);
_media_format_description & operator=(const _media_format_description & other);
#endif
media_format_family family;
uint32 _reserved_[3];
union {
media_beos_description beos;
media_quicktime_description quicktime;
media_avi_description avi;
media_asf_description asf;
media_mpeg_description mpeg;
media_wav_description wav;
media_aiff_description aiff;
media_misc_description misc;
media_avr_description avr;
uint32 _reserved_[12];
} u;
} media_format_description;
#if defined(__cplusplus)
namespace BPrivate {
class addon_list;
void dec_load_hook(void *arg, image_id imgid);
void extractor_load_hook(void *arg, image_id imgid);
class Extractor;
}
class BMediaFormats {
public:
BMediaFormats();
virtual ~BMediaFormats();
status_t InitCheck();
// Make sure you memset() your descs to 0 before you start filling
// them in! Else you may register some bogus value.
enum make_format_flags {
B_EXCLUSIVE = 0x1, // Fail if this format has already been registered
B_NO_MERGE = 0x2, // Don't re-number any formats if there are multiple
// clashing previous registrations, but fail instead
B_SET_DEFAULT = 0x4 // Set the first format to be the default for the
// format family (when registering more than one in
// the same family). Only use in Encoder add-ons.
};
status_t MakeFormatFor(
const media_format_description * descs,
int32 desc_count,
media_format * io_format,
uint32 flags = 0,
void * _reserved = 0);
status_t GetFormatFor(
const media_format_description & desc,
media_format * out_format);
// convenience functions
static status_t GetBeOSFormatFor(
uint32 fourcc, media_format * out_format,
media_type type = B_MEDIA_UNKNOWN_TYPE);
static status_t GetAVIFormatFor(
uint32 fourcc, media_format * out_format,
media_type type = B_MEDIA_UNKNOWN_TYPE);
static status_t GetQuicktimeFormatFor(
uint32 vendor, uint32 fourcc, media_format * out_format,
media_type type = B_MEDIA_UNKNOWN_TYPE);
status_t GetCodeFor(
const media_format & format,
media_format_family family,
media_format_description * out_description);
status_t RewindFormats();
status_t GetNextFormat(
media_format * out_format,
media_format_description * out_description);
// You need to lock/unlock (only) when using RewindFormats()/GetNextFormat()
bool Lock();
void Unlock();
/* --- begin deprecated API --- */
status_t MakeFormatFor(
const media_format_description & desc,
const media_format & in_format,
media_format * out_format);
private:
friend class BPrivate::addon_list;
friend void BPrivate::dec_load_hook(void *arg, image_id imgid);
friend void BPrivate::extractor_load_hook(void * arg, image_id imgid);
friend class BMediaDecoder;
friend class BMediaTrack;
friend class BPrivate::Extractor;
char _reserved_messenger[24]; // sizeof(BMessenger) 24
char _reserved_list[28]; // sizeof(BList) 28
char _reserved_locker[32]; // sizeof(BLocker) 36
int32 m_lock_count;
static int32 s_cleared;
static BMessenger s_server;
static BList s_formats;
static BLocker s_lock;
int32 m_index;
void clear_formats();
static void ex_clear_formats_imp();
static void clear_formats_imp();
status_t get_formats();
static status_t get_formats_imp();
static BMessenger & get_server();
static status_t bind_addon(
const char * addon,
const media_format * formats,
int32 count);
static bool is_bound(
const char * addon,
const media_format * formats,
int32 count);
static status_t find_addons(
const media_format * format,
BPrivate::addon_list & addons);
};
_IMPEXP_MEDIA bool operator==(const media_format_description & a, const media_format_description & b);
_IMPEXP_MEDIA bool operator<(const media_format_description & a, const media_format_description & b);
_IMPEXP_MEDIA bool operator==(const GUID & a, const GUID & b);
_IMPEXP_MEDIA bool operator<(const GUID & a, const GUID & b);
#endif
#endif /* _MEDIA_TYPES_H */
+340
View File
@@ -0,0 +1,340 @@
/*******************************************************************************
/
/ File: MediaNode.h
/
/ Description: BMediaNode is the indirect base class for all Media Kit participants.
/ However, you should use the more specific BBufferConsumer, BBufferProducer
/ and others rather than BMediaNode directly. It's OK to multiply inherit.
/
/ Copyright 1997-98, Be Incorporated, All Rights Reserved
/
*******************************************************************************/
#if !defined(_MEDIA_NODE_H)
#define _MEDIA_NODE_H
#include <MediaDefs.h>
#include <Point.h>
#include <new>
class BMediaAddOn;
class media_node {
public:
media_node();
~media_node();
media_node_id node;
port_id port;
uint32 kind;
static media_node null;
private:
uint32 _reserved_[3];
};
struct media_input {
media_input();
~media_input();
media_node node;
media_source source;
media_destination destination;
media_format format;
char name[B_MEDIA_NAME_LENGTH];
private:
uint32 _reserved_media_input_[4];
};
struct media_output {
media_output();
~media_output();
media_node node;
media_source source;
media_destination destination;
media_format format;
char name[B_MEDIA_NAME_LENGTH];
private:
uint32 _reserved_media_output_[4];
};
struct live_node_info {
live_node_info();
~live_node_info();
media_node node;
BPoint hint_point;
char name[B_MEDIA_NAME_LENGTH];
private:
char reserved[160];
};
struct media_request_info
{
enum what_code
{
B_SET_VIDEO_CLIPPING_FOR = 1,
B_REQUEST_FORMAT_CHANGE,
B_SET_OUTPUT_ENABLED,
B_SET_OUTPUT_BUFFERS_FOR,
B_FORMAT_CHANGED = 4097
};
what_code what;
int32 change_tag;
status_t status;
int32 cookie;
void * user_data;
media_source source;
media_destination destination;
media_format format;
uint32 _reserved_[32];
};
struct media_node_attribute
{
enum {
B_R40_COMPILED = 1, // has this attribute if compiled using R4.0 headers
B_USER_ATTRIBUTE_NAME = 0x1000000,
B_FIRST_USER_ATTRIBUTE
};
uint32 what;
uint32 flags; // per attribute
int64 data; // per attribute
};
class BMediaNode
{
protected:
/* this has to be on top rather than bottom to force a vtable in mwcc */
virtual ~BMediaNode(); /* should be called through Release() */
public:
enum run_mode {
B_OFFLINE = 1, /* data accurate, no realtime constraint */
B_DECREASE_PRECISION, /* when slipping, try to catch up */
B_INCREASE_LATENCY, /* when slipping, increase playout delay */
B_DROP_DATA, /* when slipping, skip data */
B_RECORDING /* you're on the receiving end of recording; buffers are guaranteed to be late */
};
BMediaNode * Acquire(); /* return itself */
BMediaNode * Release(); /* release will decrement refcount, and delete if 0 */
const char * Name() const;
media_node_id ID() const;
uint64 Kinds() const;
media_node Node() const;
run_mode RunMode() const;
BTimeSource * TimeSource() const;
/* this port is what a media node listens to for commands */
virtual port_id ControlPort() const;
virtual BMediaAddOn* AddOn(
int32 * internal_id) const = 0; /* Who instantiated you -- or NULL for app class */
/* These will be sent to anyone watching the MediaRoster. */
/* The message field "be:node_id" will contain the node ID. */
enum node_error {
/* Note that these belong with the notifications in MediaDefs.h! */
/* They are here to provide compiler type checking in ReportError(). */
B_NODE_FAILED_START = 'TRI0',
B_NODE_FAILED_STOP, // TRI1
B_NODE_FAILED_SEEK, // TRI2
B_NODE_FAILED_SET_RUN_MODE, // TRI3
B_NODE_FAILED_TIME_WARP, // TRI4
B_NODE_FAILED_PREROLL, // TRI5
B_NODE_FAILED_SET_TIME_SOURCE_FOR, // TRI6
/* display this node with a blinking exclamation mark or something */
B_NODE_IN_DISTRESS // TRI7
/* TRIA and up are used in MediaDefs.h */
};
protected:
/* Send one of the above codes to anybody who's watching. */
status_t ReportError(
node_error what,
const BMessage * info = NULL); /* String "message" for instance */
/* When you've handled a stop request, call this function. If anyone is */
/* listening for stop information from you, they will be notified. Especially */
/* important for offline capable Nodes. */
status_t NodeStopped(
bigtime_t whenPerformance); // performance time
void TimerExpired(
bigtime_t notifyPoint, // performance time
int32 cookie,
status_t error = B_OK);
explicit BMediaNode( /* constructor sets refcount to 1 */
const char * name);
status_t WaitForMessage(
bigtime_t waitUntil,
uint32 flags = 0,
void * _reserved_ = 0);
/* These don't return errors; instead, they use the global error condition reporter. */
/* A node is required to have a queue of at least one pending command (plus TimeWarp) */
/* and is recommended to allow for at least one pending command of each type. */
/* Allowing an arbitrary number of outstanding commands might be nice, but apps */
/* cannot depend on that happening. */
virtual void Start(
bigtime_t performance_time);
virtual void Stop(
bigtime_t performance_time,
bool immediate);
virtual void Seek(
bigtime_t media_time,
bigtime_t performance_time);
virtual void SetRunMode(
run_mode mode);
virtual void TimeWarp(
bigtime_t at_real_time,
bigtime_t to_performance_time);
virtual void Preroll();
virtual void SetTimeSource(
BTimeSource * time_source);
public:
virtual status_t HandleMessage(
int32 message,
const void * data,
size_t size);
void HandleBadMessage( /* call this with messages you and your superclasses don't recognize */
int32 code,
const void * buffer,
size_t size);
/* Called from derived system classes; you don't need to */
void AddNodeKind(
uint64 kind);
// These were not in 4.0.
// We added them in 4.1 for future use. They just call
// the default global versions for now.
void * operator new(
size_t size);
void * operator new(
size_t size,
const nothrow_t &) throw();
void operator delete(
void * ptr);
#if !__MWERKS__
// there's a bug in MWCC under R4.1 and earlier
void operator delete(
void * ptr,
const nothrow_t &) throw();
#endif
protected:
/* Called when requests have completed, or failed. */
virtual status_t RequestCompleted( /* reserved 0 */
const media_request_info & info);
private:
friend class BTimeSource;
friend class _BTimeSourceP;
friend class BMediaRoster;
friend class _BMediaRosterP;
friend class MNodeManager;
friend class BBufferProducer; // for getting _mNodeID
// Deprecated in 4.1
int32 IncrementChangeTag();
int32 ChangeTag();
int32 MintChangeTag();
status_t ApplyChangeTag(
int32 previously_reserved);
/* Mmmh, stuffing! */
protected:
virtual status_t DeleteHook(BMediaNode * node); /* reserved 1 */
virtual void NodeRegistered(); /* reserved 2 */
public:
/* fill out your attributes in the provided array, returning however many you have. */
virtual status_t GetNodeAttributes( /* reserved 3 */
media_node_attribute * outAttributes,
size_t inMaxCount);
virtual status_t AddTimer(
bigtime_t at_performance_time,
int32 cookie);
private:
status_t _Reserved_MediaNode_0(void *); /* DeleteHook() */
status_t _Reserved_MediaNode_1(void *); /* RequestCompletionHook() */
status_t _Reserved_MediaNode_2(void *); /* NodeRegistered() */
status_t _Reserved_MediaNode_3(void *); /* GetNodeAttributes() */
status_t _Reserved_MediaNode_4(void *); /* AddTimer() */
virtual status_t _Reserved_MediaNode_5(void *);
virtual status_t _Reserved_MediaNode_6(void *);
virtual status_t _Reserved_MediaNode_7(void *);
virtual status_t _Reserved_MediaNode_8(void *);
virtual status_t _Reserved_MediaNode_9(void *);
virtual status_t _Reserved_MediaNode_10(void *);
virtual status_t _Reserved_MediaNode_11(void *);
virtual status_t _Reserved_MediaNode_12(void *);
virtual status_t _Reserved_MediaNode_13(void *);
virtual status_t _Reserved_MediaNode_14(void *);
virtual status_t _Reserved_MediaNode_15(void *);
BMediaNode(); /* private unimplemented */
BMediaNode(
const BMediaNode & clone);
BMediaNode & operator=(
const BMediaNode & clone);
BMediaNode( /* constructor sets refcount to 1 */
const char * name,
media_node_id id,
uint32 kinds);
media_node_id fNodeID;
BTimeSource * fTimeSource;
int32 fRefCount;
char fName[B_MEDIA_NAME_LENGTH];
run_mode fRunMode;
int32 _mChangeCount; // deprecated
int32 _mChangeCountReserved; // deprecated
uint64 fKinds;
media_node_id fTimeSourceID;
bool _mReservedBool[4];
mutable port_id fControlPort;
uint32 _reserved_media_node_[13];
protected:
static int32 NewChangeTag(); // for use by BBufferConsumer, mostly
private:
// dont' rename this one, it's static and needed for binary compatibility
static int32 _m_changeTag; // not to be confused with _mChangeCount
};
#endif /* _MEDIA_NODE_H */
+428
View File
@@ -0,0 +1,428 @@
/*******************************************************************************
/
/ File: MediaRoster.h
/
/ Description: The BMediaRoster is the main application interface to the Media Kit
/
/ Copyright 1997-98, Be Incorporated, All Rights Reserved
/
*******************************************************************************/
#if !defined(_MEDIA_ROSTER_H)
#define _MEDIA_ROSTER_H
#include <map>
#include <MediaDefs.h>
#include <MediaNode.h>
#include <config_manager.h>
class BMimeType;
struct dormant_flavor_info;
class BMediaAddOn;
class BMediaRoster : public BLooper
{
public:
status_t GetVideoInput(
media_node * out_node);
status_t GetAudioInput(
media_node * out_node);
status_t GetVideoOutput(
media_node * out_node);
status_t GetAudioMixer(
media_node * out_node);
status_t GetAudioOutput(
media_node * out_node); /* Use the mixer rather than the output for most needs! */
status_t GetAudioOutput(
media_node * out_node,
int32 * out_input_id,
BString * out_input_name);
status_t GetTimeSource(
media_node * out_node);
status_t SetVideoInput(
const media_node & producer);
status_t SetVideoInput(
const dormant_node_info & producer);
status_t SetAudioInput(
const media_node & producer);
status_t SetAudioInput(
const dormant_node_info & producer);
status_t SetVideoOutput(
const media_node & consumer);
status_t SetVideoOutput(
const dormant_node_info & consumer);
status_t SetAudioOutput(
const media_node & consumer);
status_t SetAudioOutput(
const media_input & input_to_output);
status_t SetAudioOutput(
const dormant_node_info & consumer);
/* Get a media_node from a node ID -- this is how you reference your own nodes! */
status_t GetNodeFor(
media_node_id node,
media_node * clone);
status_t GetSystemTimeSource( /* typically, you want to use GetTimeSource() */
media_node * clone);
status_t ReleaseNode( /* might shut down Node if you're last */
const media_node & node);
BTimeSource * MakeTimeSourceFor( /* Release() the object when done */
const media_node & for_node);
/* note that the media_source and media_destination found in */
/* out_output and out_input are the ones actually used; from and to */
/* are only "hints" that the app should not use once a real connection */
/* has been established */
status_t Connect(
const media_source & from,
const media_destination & to,
media_format * io_format,
media_output * out_output,
media_input * out_input);
enum connect_flags {
B_CONNECT_MUTED = 0x1
};
status_t Connect(
const media_source & from,
const media_destination & to,
media_format * io_format,
media_output * out_output,
media_input * out_input,
uint32 in_flags,
void * _reserved = 0);
status_t Disconnect(
media_node_id source_node,
const media_source & source,
media_node_id destination_node,
const media_destination & destination);
status_t StartNode(
const media_node & node,
bigtime_t at_performance_time);
status_t StopNode(
const media_node & node,
bigtime_t at_performance_time,
bool immediate = false); /* immediate -> at_time is insignificant */
status_t SeekNode(
const media_node & node,
bigtime_t to_media_time,
bigtime_t at_performance_time = 0 /* if running */ );
status_t StartTimeSource(
const media_node & node,
bigtime_t at_real_time);
status_t StopTimeSource(
const media_node & node,
bigtime_t at_real_time,
bool immediate = false);
status_t SeekTimeSource(
const media_node & node,
bigtime_t to_performance_time,
bigtime_t at_real_time);
status_t SyncToNode(
const media_node & node,
bigtime_t at_time,
bigtime_t timeout = B_INFINITE_TIMEOUT);
status_t SetRunModeNode(
const media_node & node,
BMediaNode::run_mode mode);
status_t PrerollNode( /* synchronous */
const media_node & node);
status_t RollNode(
const media_node & node,
bigtime_t startPerformance,
bigtime_t stopPerformance,
bigtime_t atMediaTime = -B_INFINITE_TIMEOUT);
status_t SetProducerRunModeDelay( /* should only be used with B_RECORDING */
const media_node & node,
bigtime_t delay,
BMediaNode::run_mode mode = BMediaNode::B_RECORDING);
status_t SetProducerRate( /* not necessarily supported by node */
const media_node & producer,
int32 numer,
int32 denom);
/* Nodes will have available inputs/outputs as long as they are capable */
/* of accepting more connections. The node may create an additional */
/* output or input as the currently available is taken into usage. */
status_t GetLiveNodeInfo(
const media_node & node,
live_node_info * out_live_info);
status_t GetLiveNodes(
live_node_info * out_live_nodes,
int32 * io_total_count,
const media_format * has_input = NULL,
const media_format * has_output = NULL,
const char * name = NULL,
uint64 node_kinds = 0); /* B_BUFFER_PRODUCER etc */
status_t GetFreeInputsFor(
const media_node & node,
media_input * out_free_inputs,
int32 buf_num_inputs,
int32 * out_total_count,
media_type filter_type = B_MEDIA_UNKNOWN_TYPE);
status_t GetConnectedInputsFor(
const media_node & node,
media_input * out_active_inputs,
int32 buf_num_inputs,
int32 * out_total_count);
status_t GetAllInputsFor(
const media_node & node,
media_input * out_inputs,
int32 buf_num_inputs,
int32 * out_total_count);
status_t GetFreeOutputsFor(
const media_node & node,
media_output * out_free_outputs,
int32 buf_num_outputs,
int32 * out_total_count,
media_type filter_type = B_MEDIA_UNKNOWN_TYPE);
status_t GetConnectedOutputsFor(
const media_node & node,
media_output * out_active_outputs,
int32 buf_num_outputs,
int32 * out_total_count);
status_t GetAllOutputsFor(
const media_node & node,
media_output * out_outputs,
int32 buf_num_outputs,
int32 * out_total_count);
status_t StartWatching(
const BMessenger & where);
status_t StartWatching(
const BMessenger & where,
int32 notificationType);
status_t StartWatching(
const BMessenger & where,
const media_node & node,
int32 notificationType);
status_t StopWatching(
const BMessenger & where);
status_t StopWatching(
const BMessenger & where,
int32 notificationType);
status_t StopWatching(
const BMessenger & where,
const media_node & node,
int32 notificationType);
status_t RegisterNode(
BMediaNode * node);
status_t UnregisterNode(
BMediaNode * node);
static BMediaRoster * Roster( // will create if there isn't one
status_t * out_error = NULL); // thread safe for multiple calls to Roster()
static BMediaRoster * CurrentRoster(); // won't create it if there isn't one
// not thread safe if you call Roster() at the same time
status_t SetTimeSourceFor(
media_node_id node,
media_node_id time_source);
status_t GetParameterWebFor(
const media_node & node,
BParameterWeb ** out_web);
status_t StartControlPanel(
const media_node & node,
BMessenger * out_messenger = NULL);
status_t GetDormantNodes(
dormant_node_info * out_info,
int32 * io_count,
const media_format * has_input = NULL,
const media_format * has_output = NULL,
const char * name = NULL,
uint64 require_kinds = 0,
uint64 deny_kinds = 0);
status_t InstantiateDormantNode(
const dormant_node_info & in_info,
media_node * out_node,
uint32 flags /* currently B_FLAVOR_IS_GLOBAL or B_FLAVOR_IS_LOCAL */ );
status_t InstantiateDormantNode(
const dormant_node_info & in_info,
media_node * out_node);
status_t GetDormantNodeFor(
const media_node & node,
dormant_node_info * out_info);
status_t GetDormantFlavorInfoFor(
const dormant_node_info & in_dormant,
dormant_flavor_info * out_flavor);
status_t GetLatencyFor(
const media_node & producer,
bigtime_t * out_latency);
status_t GetInitialLatencyFor(
const media_node & producer,
bigtime_t * out_latency,
uint32 * out_flags = 0);
status_t GetStartLatencyFor(
const media_node & time_source,
bigtime_t * out_latency);
status_t GetFileFormatsFor(
const media_node & file_interface,
media_file_format * out_formats,
int32 * io_num_infos);
status_t SetRefFor(
const media_node & file_interface,
const entry_ref & file,
bool create_and_truncate,
bigtime_t * out_length); /* if create is false */
status_t GetRefFor(
const media_node & node,
entry_ref * out_file,
BMimeType * mime_type = NULL);
status_t SniffRefFor(
const media_node & file_interface,
const entry_ref & file,
BMimeType * mime_type,
float * out_capability);
/* This is the generic "here's a file, now can someone please play it" interface */
status_t SniffRef(
const entry_ref & file,
uint64 require_node_kinds, /* if you need an EntityInterface or BufferConsumer or something */
dormant_node_info * out_node,
BMimeType * mime_type = NULL);
status_t GetDormantNodeForType(
const BMimeType & type,
uint64 require_node_kinds,
dormant_node_info * out_node);
status_t GetReadFileFormatsFor(
const dormant_node_info & in_node,
media_file_format * out_read_formats,
int32 in_read_count,
int32 * out_read_count);
status_t GetWriteFileFormatsFor(
const dormant_node_info & in_node,
media_file_format * out_write_formats,
int32 in_write_count,
int32 * out_write_count);
status_t GetFormatFor(
const media_output & output,
media_format * io_format,
uint32 flags = 0);
status_t GetFormatFor(
const media_input & input,
media_format * io_format,
uint32 flags = 0);
status_t GetFormatFor(
const media_node & node,
media_format * io_format,
float quality = B_MEDIA_ANY_QUALITY);
ssize_t GetNodeAttributesFor(
const media_node & node,
media_node_attribute * outArray,
size_t inMaxCount);
media_node_id NodeIDFor(
port_id source_or_destination_port);
status_t GetInstancesFor(
media_addon_id addon,
int32 flavor,
media_node_id * out_id,
int32 * io_count = 0); // default to 1
status_t SetRealtimeFlags(
uint32 in_enabled);
status_t GetRealtimeFlags(
uint32 * out_enabled);
ssize_t AudioBufferSizeFor(
int32 channel_count,
uint32 sample_format,
float frame_rate,
bus_type bus_kind);
/* Use MediaFlags to inquire about specific features of the Media Kit. */
/* Returns < 0 for "not present", positive size for output data size. */
/* 0 means that the capability is present, but no data about it. */
static ssize_t MediaFlags(
media_flags cap,
void * buf,
size_t maxSize);
/* BLooper overrides */
virtual void MessageReceived(
BMessage * message);
virtual bool QuitRequested();
virtual BHandler * ResolveSpecifier(
BMessage *msg,
int32 index,
BMessage *specifier,
int32 form,
const char *property);
virtual status_t GetSupportedSuites(
BMessage *data);
~BMediaRoster();
private:
// deprecated call
status_t SetOutputBuffersFor(
const media_source & output,
BBufferGroup * group,
bool will_reclaim = false);
/* FBC stuffing (Mmmh, Stuffing!) */
virtual status_t _Reserved_MediaRoster_0(void *);
virtual status_t _Reserved_MediaRoster_1(void *);
virtual status_t _Reserved_MediaRoster_2(void *);
virtual status_t _Reserved_MediaRoster_3(void *);
virtual status_t _Reserved_MediaRoster_4(void *);
virtual status_t _Reserved_MediaRoster_5(void *);
virtual status_t _Reserved_MediaRoster_6(void *);
virtual status_t _Reserved_MediaRoster_7(void *);
friend class _DefaultDeleter;
friend class _BMediaRosterP;
friend class _HostApp;
friend class MLatentManager;
friend class BBufferProducer;
friend class media_node;
friend class BBuffer;
friend class BMediaNode;
static bool _isMediaServer;
BMediaRoster();
static port_id _mReplyPort;
static int32 _mReplyPortRes;
static int32 _mReplyPortUnavailCount;
uint32 _reserved_media_roster_[67];
static BMediaRoster * _sDefault;
static status_t ParseCommand(
BMessage & reply);
status_t GetDefaultInfo(
media_node_id for_default,
BMessage & out_config);
status_t SetRunningDefault(
media_node_id for_default,
const media_node & node);
static port_id checkout_reply_port(
const char * name = NULL);
static void checkin_reply_port(
port_id port);
};
#endif /* _MEDIA_ROSTER_H */
+122
View File
@@ -0,0 +1,122 @@
/*******************************************************************************
/
/ File: ControlTheme.h
/
/ Description: A BMediaTheme is something which can live in an add-on and is
/ responsible for creating BViews or BControls from a BParameterWeb and its
/ set of BMControls. This way, different "looks" for Media Kit control panels
/ can be achieved.
/
/ Copyright 1997-98, Be Incorporated, All Rights Reserved
/
*******************************************************************************/
#if !defined(_CONTROL_THEME_H)
#define _CONTROL_THEME_H
#include <Entry.h>
#include <MediaDefs.h>
class BParameterWeb;
class BMediaTheme
{
public:
virtual ~BMediaTheme();
const char * Name();
const char * Info();
int32 ID();
bool GetRef(
entry_ref * out_ref);
static BView * ViewFor(
BParameterWeb * web,
const BRect * hintRect = NULL,
BMediaTheme * using_theme = NULL);
/* This function takes possession of default_theme, even it if returns error */
static status_t SetPreferredTheme(
BMediaTheme * default_theme = NULL);
static BMediaTheme * PreferredTheme();
virtual BControl * MakeControlFor(
BParameter * control) = 0;
enum bg_kind {
B_GENERAL_BG = 0,
B_SETTINGS_BG,
B_PRESENTATION_BG,
B_EDIT_BG,
B_CONTROL_BG,
B_HILITE_BG
};
enum fg_kind {
B_GENERAL_FG = 0,
B_SETTINGS_FG,
B_PRESENTATION_FG,
B_EDIT_FG,
B_CONTROL_FG,
B_HILITE_FG
};
virtual BBitmap * BackgroundBitmapFor(
bg_kind bg = B_GENERAL_BG);
virtual rgb_color BackgroundColorFor(
bg_kind bg = B_GENERAL_BG);
virtual rgb_color ForegroundColorFor(
fg_kind fg = B_GENERAL_FG);
protected:
BMediaTheme(
const char * name,
const char * info,
const entry_ref * add_on = 0,
int32 theme_id = 0);
virtual BView * MakeViewFor(
BParameterWeb * web,
const BRect * hintRect = NULL) = 0;
static BControl * MakeFallbackViewFor(
BParameter * control);
private:
BMediaTheme(); /* private unimplemented */
BMediaTheme(
const BMediaTheme & clone);
BMediaTheme & operator=(
const BMediaTheme & clone);
/* Mmmh, stuffing! */
virtual status_t _Reserved_ControlTheme_0(void *);
virtual status_t _Reserved_ControlTheme_1(void *);
virtual status_t _Reserved_ControlTheme_2(void *);
virtual status_t _Reserved_ControlTheme_3(void *);
virtual status_t _Reserved_ControlTheme_4(void *);
virtual status_t _Reserved_ControlTheme_5(void *);
virtual status_t _Reserved_ControlTheme_6(void *);
virtual status_t _Reserved_ControlTheme_7(void *);
char * _mName;
char * _mInfo;
int32 _mID;
bool _mAddOn;
entry_ref _mAddOnRef;
uint32 _reserved_control_theme_[8];
static BMediaTheme * _mDefaultTheme;
};
/* Theme add-ons should export the functions: */
#if defined(_BUILDING_THEME_ADDON)
extern "C" _EXPORT BMediaTheme * make_theme(int32 id, image_id you);
extern "C" _EXPORT status_t get_theme_at(int32 n, const char ** out_name, const char ** out_info, int32 * out_id);
#endif /* _BUILDING_THEME_ADDON */
#endif /* _CONTROL_THEME_H */
+293
View File
@@ -0,0 +1,293 @@
#ifndef _MEDIA_TRACK_H
#define _MEDIA_TRACK_H
#include <SupportDefs.h>
#include <MediaDefs.h>
#include <MediaFormats.h>
namespace BPrivate {
class MediaExtractor;
class Decoder;
class MediaWriter;
class Encoder;
}
class BView;
class BParameterWeb;
enum media_seek_type {
B_MEDIA_SEEK_CLOSEST_FORWARD = 1,
B_MEDIA_SEEK_CLOSEST_BACKWARD = 2,
B_MEDIA_SEEK_DIRECTION_MASK = 3
};
//
// BMediaTrack gives access to a particular media track in a media file
// (as represented by BMediaFile).
//
// You always instantiate a BMediaTrack through BMediaFile::TrackAt()
// or BMediaFile::CreateTrack(). When a BMediaTrack object is
// constructed it finds the necessary decoder or encoder for the type
// of data stored in the track.
//
// Unless you created the BMediaFile() in B_MEDIA_REPLACE_MODE, you
// can only access a track for reading or writing, not both.
//
// If InitCheck() indicates no errors, then the track is ready to be
// used to read and write frames using ReadFrames() and WriteFrames().
// For video data you should always only read one frame.
//
// You can seek a track with SeekToTime() and SeekToFrame().
//
// If no codec could be found for the track, it is still possible to
// access the encoded data using ReadChunk().
//
class BMediaTrack {
protected:
// Use BMediaFile::ReleaseTrack() instead -- or it will go away
// on its own when the MediaFile is deleted.
//
virtual ~BMediaTrack();
public:
// for read-only access the BMediaTrack should be instantiated
// through BMediaFile::TrackAt()
// for write-only access the BMediaTrack should be instantiated
// through BMediaFile::CreateTrack()
status_t InitCheck() const;
// Get information about the codec being used.
status_t GetCodecInfo(media_codec_info *mci) const;
// EncodedFormat returns information about the track's
// "native" encoded format.
status_t EncodedFormat(media_format *out_format) const;
// DecodedFormat is used to negotiate the format that the codec will
// use when decoding the track's data. You pass in the format that
// that you want; the codec will find and return its "best fit"
// format. (inout_format is used as both the input and the returned
// format.) The format is typically of the B_MEDIA_RAW_AUDIO or
// B_MEDIA_RAW_VIDEO flavor.
// The data returned through ReadFrames() will be in the format that's
// returned by this function.
status_t DecodedFormat(media_format *inout_format);
// CountFrames and Duration return the total number of frame and the
// total duration (expressed in microseconds) of a track.
int64 CountFrames() const;
bigtime_t Duration() const;
// CurrentFrame and CurrentTime return the current position (expressed in
// microseconds) within the track, expressed in frame index and time.
int64 CurrentFrame() const;
bigtime_t CurrentTime() const;
// ReadFrames() fills a buffer with the next frames/samples. For a video
// track, it decodes the next frame of video in the passed buffer. For
// an audio track, it fills the buffers with the next N samples, as
// negotiated by DecodedFormat(). However, if it reaches the end of the
// file and was not able to fill the whole buffer, it returns a partial
// buffer. Upon return, out_frameCount contains the actual number of
// frame/samples returned, and the start time for the frame, expressed
// in microseconds, is in the media_header structure.
status_t ReadFrames(void *out_buffer, int64 *out_frameCount,
media_header *mh = NULL);
status_t ReadFrames(void *out_buffer, int64 *out_frameCount,
media_header *mh, media_decode_info *info);
status_t ReplaceFrames(const void *in_buffer, int64 *io_frameCount,
const media_header *mh);
// SeekToTime and SeekToFrame are used for seeking to a particular
// position in a track, expressed in either frames or microseconds.
// They return whatever position they were able to seek to. For example,
// a video codec may not be able to seek to arbitrary frames, but only to
// key frames. In this case, it would return the closest key frame before
// the specified seek point.
//
// If you want to explicitly seek to the nearest keyframe _before_ this
// frame or _after_ this frame, pass B_MEDIA_SEEK_CLOSEST_FORWARD or
// B_MEDIA_SEEK_CLOSEST_BACKWARD as the flags field.
//
status_t SeekToTime(bigtime_t *inout_time, int32 flags=0);
status_t SeekToFrame(int64 *inout_frame, int32 flags=0);
status_t FindKeyFrameForTime(bigtime_t *inout_time, int32 flags=0) const;
status_t FindKeyFrameForFrame(int64 *inout_frame, int32 flags=0) const;
// ReadChunk returns, in out_buffer, the next out_size bytes of
// data from the track. The data is not decoded -- it will be
// in its native encoded format (as specified by EncodedFormat()).
// You can not mix calling ReadChunk() and ReadFrames() -- either
// you access the track raw (i.e. with ReadChunk) or you access
// it with ReadFrames.
status_t ReadChunk(char **out_buffer, int32 *out_size,
media_header *mh = NULL);
//
// Write-only Functions
//
status_t AddCopyright(const char *data);
status_t AddTrackInfo(uint32 code, const void *data, size_t size,
uint32 flags = 0);
//
// Write num_frames of data to the track. This data is passed
// through the encoder that was specified when the MediaTrack
// was constructed.
// Pass B_MEDIA_KEY_FRAME for flags if it is.
//
status_t WriteFrames(const void *data, int32 num_frames,
int32 flags = 0);
status_t WriteFrames(const void *data, int64 num_frames,
media_encode_info *info);
//
// Write a raw chunk of (presumably already encoded data) to
// the file.
// Pass B_MEDIA_KEY_FRAME for flags if it is.
//
status_t WriteChunk(const void *data, size_t size,
uint32 flags = 0);
status_t WriteChunk(const void *data, size_t size,
media_encode_info *info);
// Flush all buffered encoded datas to disk. You should call it after
// writing the last frame to be sure all datas are flushed at the right
// offset into the file.
status_t Flush();
// These are for controlling the underlying encoder and track parameters
BParameterWeb *Web();
status_t GetParameterValue(int32 id, void *valu, size_t *size);
status_t SetParameterValue(int32 id, const void *valu, size_t size);
BView *GetParameterView();
// This is a simplified control API, only one parameter low=0.0, high=1.0
// Return B_ERROR if it's not supported by the current encoder.
status_t GetQuality(float *quality);
status_t SetQuality(float quality);
status_t GetEncodeParameters(encode_parameters *parameters) const;
status_t SetEncodeParameters(encode_parameters *parameters);
virtual status_t Perform(int32 selector, void * data);
private:
// for read-only access to a track
BMediaTrack(BPrivate::MediaExtractor *extractor, int32 stream);
// for write-only access to a BMediaTrack
BMediaTrack(BPrivate::MediaWriter *writer,
int32 stream_num,
media_format *in_format,
BPrivate::Encoder *encoder,
media_codec_info *mci);
status_t TrackInfo(media_format *out_format, void **out_info,
int32 *out_infoSize);
status_t fErr;
BPrivate::Decoder *fDecoder;
int32 fDecoderID;
BPrivate::MediaExtractor *fExtractor;
int32 fStream;
int64 fCurFrame;
bigtime_t fCurTime;
media_codec_info fMCI;
BPrivate::Encoder *fEncoder;
int32 fEncoderID;
BPrivate::MediaWriter *fWriter;
media_format fWriterFormat;
void *fExtractorCookie;
protected:
int32 EncoderID() { return fEncoderID; };
private:
friend class BMediaFile;
friend class BPrivate::Decoder;
BMediaTrack();
BMediaTrack(const BMediaTrack&);
BMediaTrack& operator=(const BMediaTrack&);
static BPrivate::Decoder * find_decoder(BMediaTrack *track, int32 *id);
/* fbc data and virtuals */
uint32 _reserved_BMediaTrack_[31];
virtual status_t _Reserved_BMediaTrack_0(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_1(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_2(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_3(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_4(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_5(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_6(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_7(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_8(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_9(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_10(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_11(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_12(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_13(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_14(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_15(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_16(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_17(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_18(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_19(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_20(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_21(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_22(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_23(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_24(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_25(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_26(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_27(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_28(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_29(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_30(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_31(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_32(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_33(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_34(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_35(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_36(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_37(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_38(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_39(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_40(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_41(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_42(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_43(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_44(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_45(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_46(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_47(int32 arg, ...);
};
#endif
+523
View File
@@ -0,0 +1,523 @@
/*******************************************************************************
/
/ File: ParameterWeb.h
/
/ Description: A BParameterWeb is a description of media controls within a BControllable
/ Media Kit Node.
/ BParameter, BParameterGroup, BContinuousParameter, BDiscreteParameter and
/ BNullParameter are "data classes" used to describe the relation within a
/ BParameterWeb. These are NOT direct visible classes like BControls; just data
/ containers which applications can use to decide what kind of views to create.
/
/ Copyright 1997-98, Be Incorporated, All Rights Reserved
/
*******************************************************************************/
#if !defined(_CONTROL_WEB_H)
#define _CONTROL_WEB_H
#include <MediaDefs.h>
#include <Flattenable.h>
#include <MediaNode.h>
#if !defined(_PR3_COMPATIBLE_)
enum {
B_MEDIA_PARAMETER_TYPE = 'BMCT',
B_MEDIA_PARAMETER_WEB_TYPE = 'BMCW',
B_MEDIA_PARAMETER_GROUP_TYPE= 'BMCG'
};
#endif
// It is highly unfortunate that a linker bug forces these symbols out
// from the BParameter class. Hope they don't collide with anything else.
/* These are control KINDs */
/* kind used when you don't know or care */
extern _IMPEXP_MEDIA const char * const B_GENERIC;
/* kinds used for sliders */
extern _IMPEXP_MEDIA const char * const B_MASTER_GAIN; /* Main Volume */
extern _IMPEXP_MEDIA const char * const B_GAIN;
extern _IMPEXP_MEDIA const char * const B_BALANCE;
extern _IMPEXP_MEDIA const char * const B_FREQUENCY; /* like a radio tuner */
extern _IMPEXP_MEDIA const char * const B_LEVEL; /* like for effects */
extern _IMPEXP_MEDIA const char * const B_SHUTTLE_SPEED; /* Play, SloMo, Scan 1.0 == regular */
extern _IMPEXP_MEDIA const char * const B_CROSSFADE; /* 0 == first input, +100 == second input */
extern _IMPEXP_MEDIA const char * const B_EQUALIZATION; /* depth (dB) */
/* kinds used for compressors */
extern _IMPEXP_MEDIA const char * const B_COMPRESSION; /* 0% == no compression, 99% == 100:1 compression */
extern _IMPEXP_MEDIA const char * const B_QUALITY; /* 0% == full compression, 100% == no compression */
extern _IMPEXP_MEDIA const char * const B_BITRATE; /* in bits/second */
extern _IMPEXP_MEDIA const char * const B_GOP_SIZE; /* Group Of Pictures. a k a "Keyframe every N frames" */
/* kinds used for selectors */
extern _IMPEXP_MEDIA const char * const B_MUTE; /* 0 == thru, 1 == mute */
extern _IMPEXP_MEDIA const char * const B_ENABLE; /* 0 == disable, 1 == enable */
extern _IMPEXP_MEDIA const char * const B_INPUT_MUX; /* "value" 1-N == input selected */
extern _IMPEXP_MEDIA const char * const B_OUTPUT_MUX; /* "value" 1-N == output selected */
extern _IMPEXP_MEDIA const char * const B_TUNER_CHANNEL; /* like cable TV */
extern _IMPEXP_MEDIA const char * const B_TRACK; /* like a CD player; "value" should be 1-N */
extern _IMPEXP_MEDIA const char * const B_RECSTATE; /* like mutitrack tape deck, 0 == silent, 1 == play, 2 == record */
extern _IMPEXP_MEDIA const char * const B_SHUTTLE_MODE; /* -1 == backwards, 0 == stop, 1 == play, 2 == pause/cue */
extern _IMPEXP_MEDIA const char * const B_RESOLUTION;
extern _IMPEXP_MEDIA const char * const B_COLOR_SPACE; /* "value" should be color_space */
extern _IMPEXP_MEDIA const char * const B_FRAME_RATE;
extern _IMPEXP_MEDIA const char * const B_VIDEO_FORMAT; /* 1 == NTSC-M, 2 == NTSC-J, 3 == PAL-BDGHI, 4 == PAL-M, 5 == PAL-N, 6 == SECAM, 7 == MPEG-1, 8 == MPEG-2 */
/* kinds used for junctions */
// the prefix of "WEB" is to avoid collission with an enum in Defs.h
extern _IMPEXP_MEDIA const char * const B_WEB_PHYSICAL_INPUT; /* a jack on the back of the card */
extern _IMPEXP_MEDIA const char * const B_WEB_PHYSICAL_OUTPUT;
extern _IMPEXP_MEDIA const char * const B_WEB_ADC_CONVERTER; /* from analog to digital signals */
extern _IMPEXP_MEDIA const char * const B_WEB_DAC_CONVERTER; /* from digital to analog signals */
extern _IMPEXP_MEDIA const char * const B_WEB_LOGICAL_INPUT; /* an "input" that may not be physical */
extern _IMPEXP_MEDIA const char * const B_WEB_LOGICAL_OUTPUT;
extern _IMPEXP_MEDIA const char * const B_WEB_LOGICAL_BUS; /* a logical connection point that is neither input nor output; auxilliary bus */
extern _IMPEXP_MEDIA const char * const B_WEB_BUFFER_INPUT; /* an input that corresponds to a media_input */
extern _IMPEXP_MEDIA const char * const B_WEB_BUFFER_OUTPUT;
// a simple transport control is a discrete parameter with five values (states):
// rewinding, stopped, playing, paused, and fast-forwarding
extern _IMPEXP_MEDIA const char * const B_SIMPLE_TRANSPORT;
class BList;
class BParameterGroup;
class BParameter;
class BNullParameter;
class BContinuousParameter;
class BDiscreteParameter;
/* Set these flags on parameters and groups to control how a Theme will */
/* render the Web. Hidden means, generally, "don't show". Advanced means, */
/* generally, that you can show it or not depending on your whim. */
enum media_parameter_flags {
B_HIDDEN_PARAMETER = 0x1,
B_ADVANCED_PARAMETER = 0x2
};
class BParameterWeb :
public BFlattenable
{
public:
BParameterWeb();
~BParameterWeb();
media_node Node();
BParameterGroup * MakeGroup(
const char * name);
int32 CountGroups();
BParameterGroup * GroupAt(
int32 index);
int32 CountParameters();
BParameter * ParameterAt(
int32 index);
virtual bool IsFixedSize() const;
virtual type_code TypeCode() const;
virtual ssize_t FlattenedSize() const;
virtual status_t Flatten(void *buffer, ssize_t size) const;
virtual bool AllowsTypeCode(type_code code) const;
virtual status_t Unflatten(type_code c, const void *buf, ssize_t size);
private:
friend class BParameterGroup;
friend class BControllable;
BParameterWeb(
const BParameterWeb & clone);
BParameterWeb & operator=(
const BParameterWeb & clone);
/* Mmmh, stuffing! */
virtual status_t _Reserved_ControlWeb_0(void *);
virtual status_t _Reserved_ControlWeb_1(void *);
virtual status_t _Reserved_ControlWeb_2(void *);
virtual status_t _Reserved_ControlWeb_3(void *);
virtual status_t _Reserved_ControlWeb_4(void *);
virtual status_t _Reserved_ControlWeb_5(void *);
virtual status_t _Reserved_ControlWeb_6(void *);
virtual status_t _Reserved_ControlWeb_7(void *);
BList * mGroups;
media_node mNode;
uint32 _reserved_control_web_[8];
BList * mOldRefs;
BList * mNewRefs;
void AddRefFix(
void * oldItem,
void * newItem);
};
class BParameterGroup :
public BFlattenable
{
private:
BParameterGroup(
BParameterWeb * web,
const char * name);
virtual ~BParameterGroup();
public:
BParameterWeb * Web() const;
const char * Name() const;
void SetFlags(uint32 flags);
uint32 Flags() const;
BNullParameter * MakeNullParameter(
int32 id,
media_type m_type,
const char * name,
const char * kind);
BContinuousParameter * MakeContinuousParameter(
int32 id,
media_type m_type,
const char * name,
const char * kind,
const char * unit,
float minimum,
float maximum,
float stepping);
BDiscreteParameter * MakeDiscreteParameter(
int32 id,
media_type m_type,
const char * name,
const char * kind);
BParameterGroup * MakeGroup(
const char * name);
int32 CountParameters();
BParameter * ParameterAt(
int32 index);
int32 CountGroups();
BParameterGroup * GroupAt(
int32 index);
virtual bool IsFixedSize() const;
virtual type_code TypeCode() const;
virtual ssize_t FlattenedSize() const;
virtual status_t Flatten(void *buffer, ssize_t size) const;
virtual bool AllowsTypeCode(type_code code) const;
virtual status_t Unflatten(type_code c, const void *buf, ssize_t size);
private:
BParameterGroup(); /* private unimplemented */
BParameterGroup(
const BParameterGroup & clone);
BParameterGroup & operator=(
const BParameterGroup & clone);
/* Mmmh, stuffing! */
virtual status_t _Reserved_ControlGroup_0(void *);
virtual status_t _Reserved_ControlGroup_1(void *);
virtual status_t _Reserved_ControlGroup_2(void *);
virtual status_t _Reserved_ControlGroup_3(void *);
virtual status_t _Reserved_ControlGroup_4(void *);
virtual status_t _Reserved_ControlGroup_5(void *);
virtual status_t _Reserved_ControlGroup_6(void *);
virtual status_t _Reserved_ControlGroup_7(void *);
friend class BParameterWeb;
BParameterWeb * mWeb;
BList * mControls;
BList * mGroups;
char * mName;
uint32 mFlags;
uint32 _reserved_control_group_[7];
BParameter * MakeControl(
int32 type);
};
/* After you create a BParameter, hook it up by calling AddInput() and/or AddOutput() */
/* (which will call the reciprocal in the target) and optionally call SetChannelCount() and SetMediaType() */
class BParameter :
public BFlattenable
{
public:
/* This is a parameter TYPE */
enum media_parameter_type
{
B_NULL_PARAMETER,
B_DISCRETE_PARAMETER,
B_CONTINUOUS_PARAMETER
};
media_parameter_type Type() const;
BParameterWeb * Web() const;
BParameterGroup * Group() const;
const char * Name() const;
const char * Kind() const;
const char * Unit() const;
int32 ID() const;
void SetFlags(uint32 flags);
uint32 Flags() const;
virtual type_code ValueType() = 0;
/* These functions are typically used by client apps; they will result in */
/* your BControllable getting called to read/write values. */
status_t GetValue(
void * buffer,
size_t * ioSize,
bigtime_t * when);
status_t SetValue(
const void * buffer,
size_t size,
bigtime_t when);
int32 CountChannels(); /* Number of ValueType() values; default is 1 */
void SetChannelCount( /* One value could still control e g a stereo pair */
int32 channel_count);
media_type MediaType(); /* Optional (default is B_MEDIA_NO_TYPE) */
void SetMediaType(media_type m_type);
int32 CountInputs();
BParameter * InputAt(
int32 index);
void AddInput(
BParameter * input);
int32 CountOutputs();
BParameter * OutputAt(
int32 index);
void AddOutput(
BParameter * output);
virtual bool IsFixedSize() const;
virtual type_code TypeCode() const;
virtual ssize_t FlattenedSize() const;
virtual status_t Flatten(void *buffer, ssize_t size) const;
virtual bool AllowsTypeCode(type_code code) const;
virtual status_t Unflatten(type_code c, const void *buf, ssize_t size);
private:
friend class BNullParameter;
friend class BContinuousParameter;
friend class BDiscreteParameter;
friend class BParameterGroup;
friend class BParameterWeb;
bool SwapOnUnflatten() { return mSwapDetected; }
/* Mmmh, stuffing! */
virtual status_t _Reserved_Control_0(void *);
virtual status_t _Reserved_Control_1(void *);
virtual status_t _Reserved_Control_2(void *);
virtual status_t _Reserved_Control_3(void *);
virtual status_t _Reserved_Control_4(void *);
virtual status_t _Reserved_Control_5(void *);
virtual status_t _Reserved_Control_6(void *);
virtual status_t _Reserved_Control_7(void *);
BParameter(
int32 id,
media_type m_type,
media_parameter_type type,
BParameterWeb * web,
const char * name,
const char * kind,
const char * unit);
~BParameter();
int32 mID;
media_parameter_type mType;
BParameterWeb * mWeb;
BParameterGroup * mGroup;
char * mName;
char * mKind;
char * mUnit;
BList * mInputs;
BList * mOutputs;
bool mSwapDetected;
media_type mMediaType;
int32 mChannels;
uint32 mFlags;
uint32 _reserved_control_[7];
virtual void FixRefs(
BList & old,
BList & updated);
};
class BContinuousParameter :
public BParameter
{
public:
virtual type_code ValueType();
float MinValue();
float MaxValue();
float ValueStep();
/* The "response" specifies what value to display to the user. */
/* Thus, if response is B_POLYNOMIAL with factor 2, an actual */
/* control value of 10 would be displayed to the user as 100, and */
/* if response was B_EXPONENTIAL and factor was 2, an actual */
/* value of 3 would display 8 (two to the third). The ValueStep() */
/* is given in actual control values, before the transformation for */
/* display is done. Thus, with min 0, max 4 and value step 1, and an */
/* exponential response with factor 10, you will get the displayed */
/* values 1, 10, 100, 1000 and 10000 equally spaced across a slider */
/* (or whatever UI the app puts to the parameter). */
/* The "offset" is added to the value after transformation, before display. */
/* If "resp" is negative, the resulting value/display relation is turned upside down. */
enum response {
B_UNKNOWN = 0,
B_LINEAR = 1, /* factor is direct multiplier >= 0 */
B_POLYNOMIAL, /* factor should be power; typically "2" for squared or "-1" for inverse */
B_EXPONENTIAL, /* factor should be base, typically 2 or 10 */
B_LOGARITHMIC /* factor should be base, typically 2 or 10 */
};
void SetResponse(
int resp,
float factor,
float offset);
void GetResponse(
int * resp,
float * factor,
float * offset);
virtual ssize_t FlattenedSize() const;
virtual status_t Flatten(void *buffer, ssize_t size) const;
virtual status_t Unflatten(type_code c, const void *buf, ssize_t size);
private:
/* Mmmh, stuffing! */
virtual status_t _Reserved_ContinuousParameter_0(void *);
virtual status_t _Reserved_ContinuousParameter_1(void *);
virtual status_t _Reserved_ContinuousParameter_2(void *);
virtual status_t _Reserved_ContinuousParameter_3(void *);
virtual status_t _Reserved_ContinuousParameter_4(void *);
virtual status_t _Reserved_ContinuousParameter_5(void *);
virtual status_t _Reserved_ContinuousParameter_6(void *);
virtual status_t _Reserved_ContinuousParameter_7(void *);
friend class BParameterGroup;
BContinuousParameter(
int32 id,
media_type m_type,
BParameterWeb * web,
const char * name,
const char * kind,
const char * unit,
float minimum,
float maximum,
float stepping);
~BContinuousParameter();
float mMinimum;
float mMaximum;
float mStepping;
response mResponse;
float mFactor;
float mOffset;
uint32 _reserved_control_slider_[8];
};
class BDiscreteParameter :
public BParameter
{
public:
virtual type_code ValueType();
int32 CountItems();
const char * ItemNameAt(
int32 index);
int32 ItemValueAt(
int32 index);
status_t AddItem(
int32 value,
const char * name);
status_t MakeItemsFromInputs();
status_t MakeItemsFromOutputs();
void MakeEmpty();
virtual ssize_t FlattenedSize() const;
virtual status_t Flatten(void *buffer, ssize_t size) const;
virtual status_t Unflatten(type_code c, const void *buf, ssize_t size);
private:
/* Mmmh, stuffing! */
virtual status_t _Reserved_DiscreteParameter_0(void *);
virtual status_t _Reserved_DiscreteParameter_1(void *);
virtual status_t _Reserved_DiscreteParameter_2(void *);
virtual status_t _Reserved_DiscreteParameter_3(void *);
virtual status_t _Reserved_DiscreteParameter_4(void *);
virtual status_t _Reserved_DiscreteParameter_5(void *);
virtual status_t _Reserved_DiscreteParameter_6(void *);
virtual status_t _Reserved_DiscreteParameter_7(void *);
friend class BParameterGroup;
BList * mSelections;
BList * mValues;
uint32 _reserved_control_selector_[8];
BDiscreteParameter(
int32 id,
media_type m_type,
BParameterWeb * web,
const char * name,
const char * kind);
~BDiscreteParameter();
};
class BNullParameter :
public BParameter
{
public:
virtual type_code ValueType();
virtual ssize_t FlattenedSize() const;
virtual status_t Flatten(void *buffer, ssize_t size) const;
virtual status_t Unflatten(type_code c, const void *buf, ssize_t size);
private:
/* Mmmh, stuffing! */
virtual status_t _Reserved_NullParameter_0(void *);
virtual status_t _Reserved_NullParameter_1(void *);
virtual status_t _Reserved_NullParameter_2(void *);
virtual status_t _Reserved_NullParameter_3(void *);
virtual status_t _Reserved_NullParameter_4(void *);
virtual status_t _Reserved_NullParameter_5(void *);
virtual status_t _Reserved_NullParameter_6(void *);
virtual status_t _Reserved_NullParameter_7(void *);
friend class BParameterGroup;
uint32 _reserved_control_junction_[8];
BNullParameter(
int32 id,
media_type m_type,
BParameterWeb * web,
const char * name,
const char * kind);
~BNullParameter();
};
#endif /* _CONTROL_WEB_H */
+34
View File
@@ -0,0 +1,34 @@
/******************************************************************************
File: PlaySound.h
Description: Interface for a simple beep sound.
Copyright 1995-97, Be Incorporated
******************************************************************************/
#ifndef _PLAY_SOUND_H
#define _PLAY_SOUND_H
#ifndef _BE_BUILD_H
#include <BeBuild.h>
#endif
#include <OS.h>
#include <Entry.h>
typedef sem_id sound_handle;
_IMPEXP_MEDIA
sound_handle play_sound(const entry_ref *soundRef,
bool mix,
bool queue,
bool background
);
_IMPEXP_MEDIA
status_t stop_sound(sound_handle handle);
_IMPEXP_MEDIA
status_t wait_for_sound(sound_handle handle);
#endif /* #ifndef _PLAY_SOUND_H*/
+51
View File
@@ -0,0 +1,51 @@
/*******************************************************************************
/
/ File: RealtimeAlloc.h
/
/ Description: Allocation from separate "pools" of memory. Those pools
/ will be locked in RAM if realtime allocators are turned
/ on in the BMediaRoster, so don't waste this memory unless
/ it's needed. Also, the shared pool is a scarce resource,
/ so it's better if you create your own pool for your own
/ needs and leave the shared pool for BMediaNode instances
/ and the needs of the Media Kit.
/
/ Copyright 1998-99, Be Incorporated, All Rights Reserved
/
*******************************************************************************/
#if !defined(_REALTIME_ALLOC_H)
#define _REALTIME_ALLOC_H
#include <SupportDefs.h>
#if defined(__cplusplus)
extern "C" {
#endif
typedef struct rtm_pool rtm_pool;
/* If out_pool is NULL, the default pool will be created if it isn't already. */
/* If the default pool is already created, it will return EALREADY. */
#if defined(__cplusplus)
_IMPEXP_MEDIA status_t rtm_create_pool(rtm_pool ** out_pool, size_t total_size, const char * name=NULL);
#else
_IMPEXP_MEDIA status_t rtm_create_pool(rtm_pool ** out_pool, size_t total_size, const char * name);
#endif
_IMPEXP_MEDIA status_t rtm_delete_pool(rtm_pool * pool);
/* If NULL is passed for pool, the default pool is used (if created). */
_IMPEXP_MEDIA void * rtm_alloc(rtm_pool * pool, size_t size);
_IMPEXP_MEDIA status_t rtm_free(void * data);
_IMPEXP_MEDIA status_t rtm_realloc(void ** data, size_t new_size);
_IMPEXP_MEDIA status_t rtm_size_for(void * data);
_IMPEXP_MEDIA status_t rtm_phys_size_for(void * data);
/* Return the default pool, or NULL if not yet initialized */
_IMPEXP_MEDIA rtm_pool * rtm_default_pool();
#if defined(__cplusplus)
}
#endif
#endif // _REALTIME_ALLOC_H
+111
View File
@@ -0,0 +1,111 @@
/* BSound.h */
/* Copyright 1998 Be Incorporated. All rights reserved. */
#if !defined(_SOUND_H)
#define _SOUND_H
#include <MediaDefs.h>
class BSoundFile;
namespace BPrivate {
class BTrackReader;
}
class BSound {
public:
BSound(
void * data,
size_t size,
const media_raw_audio_format & format,
bool free_when_done = false);
BSound(
const entry_ref * sound_file,
bool load_into_memory = false);
status_t InitCheck();
BSound * AcquireRef();
bool ReleaseRef();
int32 RefCount() const; // unreliable!
virtual bigtime_t Duration() const;
virtual const media_raw_audio_format & Format() const;
virtual const void * Data() const; /* returns NULL for files */
virtual off_t Size() const;
virtual bool GetDataAt(
off_t offset,
void * into_buffer,
size_t buffer_size,
size_t * out_used);
protected:
BSound(
const media_raw_audio_format & format);
virtual status_t Perform(
int32 code,
...);
private:
BSound(const BSound &); // unimplemented
BSound & operator=(const BSound &); // unimplemented
friend class BSoundPlayer;
friend class _HostApp;
void Reset();
virtual ~BSound();
void free_data();
static status_t load_entry(void * arg);
void loader_thread();
bool check_stop();
public:
virtual status_t BindTo(
BSoundPlayer * player,
const media_raw_audio_format & format);
virtual status_t UnbindFrom(
BSoundPlayer * player);
private:
status_t _Reserved_Sound_0(void *); // BindTo
status_t _Reserved_Sound_1(void *); // UnbindFrom
virtual status_t _Reserved_Sound_2(void *);
virtual status_t _Reserved_Sound_3(void *);
virtual status_t _Reserved_Sound_4(void *);
virtual status_t _Reserved_Sound_5(void *);
void * _m_data;
BMediaFile * _m_file;
int32 _m_ref_count;
status_t _m_error;
size_t _m_size;
media_raw_audio_format _m_format;
bool _m_free_when_done;
bool _m_checkStopped;
bool _m_reserved[2];
area_id _m_area;
sem_id _m_avail_sem;
sem_id _m_free_sem;
thread_id _m_loader_thread;
size_t _m_read_pos;
sem_id _m_check_token;
int32 _m_prev_sem_count;
BSoundPlayer * _m_bound_player;
int32 _m_bind_flags;
BPrivate::BTrackReader * _m_trackReader;
char m_tname[32];
uint32 _reserved_[1];
};
#endif /* _SOUND_H */
+101
View File
@@ -0,0 +1,101 @@
/******************************************************************************
File: SoundFile.h
Description: Interface for a format-insensitive sound file object.
Copyright 1995-97, Be Incorporated
******************************************************************************/
#ifndef _SOUND_FILE_H
#define _SOUND_FILE_H
#ifndef _BE_BUILD_H
#include <BeBuild.h>
#endif
#include <MediaDefs.h>
#include <Entry.h>
#include <File.h>
enum /* sound_format*/
{ B_UNKNOWN_FILE,
B_AIFF_FILE,
B_WAVE_FILE,
B_UNIX_FILE };
class BSoundFile {
public:
BSoundFile();
BSoundFile(const entry_ref *ref,
uint32 open_mode);
virtual ~BSoundFile();
status_t InitCheck() const;
status_t SetTo(const entry_ref *ref, uint32 open_mode);
int32 FileFormat() const;
int32 SamplingRate() const;
int32 CountChannels() const;
int32 SampleSize() const;
int32 ByteOrder() const;
int32 SampleFormat() const;
int32 FrameSize() const;
off_t CountFrames() const;
bool IsCompressed() const;
int32 CompressionType() const;
char *CompressionName() const;
virtual int32 SetFileFormat(int32 format);
virtual int32 SetSamplingRate(int32 fps);
virtual int32 SetChannelCount(int32 spf);
virtual int32 SetSampleSize(int32 bps);
virtual int32 SetByteOrder(int32 bord);
virtual int32 SetSampleFormat(int32 fmt);
virtual int32 SetCompressionType(int32 type);
virtual char *SetCompressionName(char *name);
virtual bool SetIsCompressed(bool tf);
virtual off_t SetDataLocation(off_t offset);
virtual off_t SetFrameCount(off_t count);
size_t ReadFrames(char *buf, size_t count);
size_t WriteFrames(char *buf, size_t count);
virtual off_t SeekToFrame(off_t n);
off_t FrameIndex() const;
off_t FramesRemaining() const;
BFile *fSoundFile;
private:
virtual void _ReservedSoundFile1();
virtual void _ReservedSoundFile2();
virtual void _ReservedSoundFile3();
int32 fFileFormat;
int32 fSamplingRate;
int32 fChannelCount;
int32 fSampleSize;
int32 fByteOrder;
int32 fSampleFormat;
off_t fByteOffset; /* offset to first sample */
off_t fFrameCount;
off_t fFrameIndex;
bool fIsCompressed;
int32 fCompressionType;
char *fCompressionName;
status_t fCStatus;
void _init_raw_stats();
status_t _ref_to_file(const entry_ref *ref);
uint32 _reserved[4];
};
#endif /* #ifndef _SOUND_FILE_H*/
+197
View File
@@ -0,0 +1,197 @@
/* SoundPlayer.h */
/* Copyright 1998 Be Incorporated. All rights reserved. */
#if !defined(_SOUND_PLAYER_H)
#define _SOUND_PLAYER_H
#include <MediaDefs.h>
#include <BufferProducer.h>
#include <Locker.h>
#include <exception>
class BSound;
class sound_error : public exception {
const char * m_str_const;
public:
sound_error(const char * str);
const char * what() const;
};
class BSoundPlayer {
friend class _SoundPlayNode;
public:
enum sound_player_notification {
B_STARTED = 1,
B_STOPPED,
B_SOUND_DONE
};
BSoundPlayer(
const char * name = NULL,
void (*PlayBuffer)(void *, void * buffer, size_t size, const media_raw_audio_format & format) = NULL,
void (*Notifier)(void *, sound_player_notification what, ...) = NULL,
void * cookie = NULL);
BSoundPlayer(
const media_raw_audio_format * format,
const char * name = NULL,
void (*PlayBuffer)(void *, void * buffer, size_t size, const media_raw_audio_format & format) = NULL,
void (*Notifier)(void *, sound_player_notification what, ...) = NULL,
void * cookie = NULL);
BSoundPlayer(
const media_node & toNode,
const media_multi_audio_format * format = NULL,
const char * name = NULL,
const media_input * input = NULL,
void (*PlayBuffer)(void *, void * buffer, size_t size, const media_raw_audio_format & format) = NULL,
void (*Notifier)(void *, sound_player_notification what, ...) = NULL,
void * cookie = NULL);
virtual ~BSoundPlayer();
status_t InitCheck(); // new in R4.1
media_raw_audio_format Format() const; // new in R4.1
status_t Start();
void Stop(
bool block = true,
bool flush = true);
typedef void (*BufferPlayerFunc)(void *, void *, size_t, const media_raw_audio_format &);
BufferPlayerFunc BufferPlayer() const;
void SetBufferPlayer(
void (*PlayBuffer)(void *, void * buffer, size_t size, const media_raw_audio_format & format));
typedef void (*EventNotifierFunc)(void *, sound_player_notification what, ...);
EventNotifierFunc EventNotifier() const;
void SetNotifier(
void (*Notifier)(void *, sound_player_notification what, ...));
void * Cookie() const;
void SetCookie(
void * cookie);
void SetCallbacks( // atomic change
void (*PlayBuffer)(void *, void * buffer, size_t size, const media_raw_audio_format & format) = NULL,
void (*Notifier)(void *, sound_player_notification what, ...) = NULL,
void * cookie = NULL);
typedef int32 play_id;
bigtime_t CurrentTime();
bigtime_t PerformanceTime();
status_t Preroll();
play_id StartPlaying(
BSound * sound,
bigtime_t at_time = 0);
play_id StartPlaying(
BSound * sound,
bigtime_t at_time,
float with_volume);
status_t SetSoundVolume(
play_id sound, // update only non-NULL values
float new_volume);
bool IsPlaying(
play_id id);
status_t StopPlaying(
play_id id);
status_t WaitForSound(
play_id id);
float Volume(); /* 0 - 1.0 */
void SetVolume( /* 0 - 1.0 */
float new_volume);
float VolumeDB( /* -xx - +xx (see GetVolumeInfo()) */
bool forcePoll = false); /* if false, cached value will be used if new enough */
void SetVolumeDB(
float volume_dB);
status_t GetVolumeInfo(
media_node * out_node,
int32 * out_parameter,
float * out_min_dB,
float * out_max_dB);
bigtime_t Latency();
virtual bool HasData();
void SetHasData( // this does more than just set a flag
bool has_data);
protected:
void SetInitError( // new in R4.1
status_t in_error);
private:
virtual status_t _Reserved_SoundPlayer_0(void *, ...);
virtual status_t _Reserved_SoundPlayer_1(void *, ...);
virtual status_t _Reserved_SoundPlayer_2(void *, ...);
virtual status_t _Reserved_SoundPlayer_3(void *, ...);
virtual status_t _Reserved_SoundPlayer_4(void *, ...);
virtual status_t _Reserved_SoundPlayer_5(void *, ...);
virtual status_t _Reserved_SoundPlayer_6(void *, ...);
virtual status_t _Reserved_SoundPlayer_7(void *, ...);
_SoundPlayNode * _m_node;
struct _playing_sound {
_playing_sound * next;
off_t cur_offset;
BSound * sound;
play_id id;
int32 delta;
int32 rate;
float volume;
};
_playing_sound * _m_sounds;
struct _waiting_sound {
_waiting_sound * next;
bigtime_t start_time;
BSound * sound;
play_id id;
int32 rate;
float volume;
};
_waiting_sound * _m_waiting;
void (*_PlayBuffer)(void * cookie, void * buffer, size_t size, const media_raw_audio_format & format);
void (*_Notifier)(void * cookie, sound_player_notification what, ...);
BLocker _m_lock;
float _m_volume;
media_input m_input;
media_output m_output;
float * _m_mix_buffer;
size_t _m_mix_buffer_size;
void * _m_cookie;
void * _m_buf;
size_t _m_bufsize;
int32 _m_has_data;
status_t _m_init_err; // new in R4.1
bigtime_t _m_perfTime;
BContinuousParameter * _m_volumeSlider;
bigtime_t _m_gotVolume;
uint32 _m_reserved[10];
void NotifySoundDone(
play_id sound,
bool got_to_play);
void get_volume_slider();
void Init(
const media_node * node,
const media_multi_audio_format * format,
const char * name,
const media_input * input,
void (*PlayBuffer)(void *, void * buffer, size_t size, const media_raw_audio_format & format),
void (*Notifier)(void *, sound_player_notification what, ...),
void * cookie);
// for B_STARTED and B_STOPPED, the argument is BSoundPlayer* (this)
// for B_SOUND_DONE, the arguments are play_id and true/false for whether it got to play data at all
virtual void Notify(
sound_player_notification what,
...);
// get data into the buffer to play -- this version will use the queued BSound system
virtual void PlayBuffer(
void * buffer,
size_t size,
const media_raw_audio_format & format);
};
#endif /* _SOUND_PLAYER_H */
+119
View File
@@ -0,0 +1,119 @@
/*****************************************************************
File: TimeCode.h
Description: Time code handling functions and class
Copyright 1998-, Be Incorporated. All Rights Reserved.
*****************************************************************/
#if !defined(_TIME_CODE_H)
#define _TIME_CODE_H
#include <SupportDefs.h>
/* Time code is always in the form HH:MM:SS:FF, it's the definition of FF that varies */
enum timecode_type {
B_TIMECODE_DEFAULT,
B_TIMECODE_100,
B_TIMECODE_75, /* CD */
B_TIMECODE_30, /* MIDI */
B_TIMECODE_30_DROP_2, /* NTSC */
B_TIMECODE_30_DROP_4, /* Brazil */
B_TIMECODE_25, /* PAL */
B_TIMECODE_24, /* Film */
B_TIMECODE_18 /* Super8 */
};
struct timecode_info {
timecode_type type;
int drop_frames;
int every_nth;
int except_nth;
int fps_div;
char name[32]; /* for popup menu etc */
char format[32]; /* for sprintf(fmt, h, m, s, f) */
char _reserved_[64];
};
_IMPEXP_MEDIA status_t us_to_timecode(bigtime_t micros, int * hours, int * minutes, int * seconds, int * frames, const timecode_info * code = NULL);
_IMPEXP_MEDIA status_t timecode_to_us(int hours, int minutes, int seconds, int frames, bigtime_t * micros, const timecode_info * code = NULL);
_IMPEXP_MEDIA status_t frames_to_timecode(int32 l_frames, int * hours, int * minutes, int * seconds, int * frames, const timecode_info * code = NULL);
_IMPEXP_MEDIA status_t timecode_to_frames(int hours, int minutes, int seconds, int frames, int32 * l_frames, const timecode_info * code = NULL);
_IMPEXP_MEDIA status_t get_timecode_description(timecode_type type, timecode_info * out_timecode);
_IMPEXP_MEDIA status_t count_timecodes();
/* we may want a set_default_timecode, too -- but that's bad from a thread standpoint */
class BTimeCode {
public:
BTimeCode();
BTimeCode(
bigtime_t us,
timecode_type type = B_TIMECODE_DEFAULT);
BTimeCode(
const BTimeCode & clone);
BTimeCode(
int hours,
int minutes,
int seconds,
int frames,
timecode_type type = B_TIMECODE_DEFAULT);
~BTimeCode();
void SetData(
int hours,
int minutes,
int seconds,
int frames);
status_t SetType(
timecode_type type);
void SetMicroseconds(
bigtime_t us);
void SetLinearFrames(
int32 linear_frames);
BTimeCode & operator=(
const BTimeCode & clone);
bool operator==(
const BTimeCode & other) const;
bool operator<(
const BTimeCode & other) const;
BTimeCode & operator+=(
const BTimeCode & other);
BTimeCode & operator-=(
const BTimeCode & other);
BTimeCode operator+(
const BTimeCode & other) const;
BTimeCode operator-(
const BTimeCode & other) const;
int Hours() const;
int Minutes() const;
int Seconds() const;
int Frames() const;
timecode_type Type() const;
void GetData(
int * out_hours,
int * out_minutes,
int * out_seconds,
int * out_frames,
timecode_type * out_type = NULL) const;
bigtime_t Microseconds() const;
int32 LinearFrames() const;
void GetString(
char * str) const; /* at least 24 bytes */
private:
int m_hours;
int m_minutes;
int m_seconds;
int m_frames;
timecode_info m_info;
};
#endif /* _TIME_CODE_H */
+141
View File
@@ -0,0 +1,141 @@
/*******************************************************************************
/
/ File: TimeSource.h
/
/ Description: A BTimeSource is something to which others can slave timing information
/ using the Media Kit.
/
/ Copyright 1997-98, Be Incorporated, All Rights Reserved
/
*******************************************************************************/
#if !defined(_TIME_SOURCE_H)
#define _TIME_SOURCE_H
#include <MediaDefs.h>
#include <MediaNode.h>
class _BSlaveNodeStorageP;
struct _time_transmit_buf;
class BTimeSource :
public virtual BMediaNode
{
protected:
/* this has to be at the top to force a vtable */
virtual ~BTimeSource();
public:
virtual status_t SnoozeUntil( /* returns error if stopped */
bigtime_t performance_time,
bigtime_t with_latency = 0,
bool retry_signals = false);
bigtime_t Now(); /* convenience, less accurate */
bigtime_t PerformanceTimeFor( /* all three go through GetTime() */
bigtime_t real_time);
bigtime_t RealTimeFor(
bigtime_t performance_time,
bigtime_t with_latency);
bool IsRunning();
status_t GetTime( /* return B_OK if reading is usable */
bigtime_t * performance_time,
bigtime_t * real_time,
float * drift);
static bigtime_t RealTime(); /* this produces real time, nothing else is guaranteed to */
status_t GetStartLatency(
bigtime_t * out_latency);
protected:
BTimeSource();
virtual status_t HandleMessage(
int32 message,
const void * data,
size_t size);
void PublishTime( /* call this at convenient times to update approximation */
bigtime_t performance_time,
bigtime_t real_time,
float drift);
void BroadcastTimeWarp(
bigtime_t at_real_time,
bigtime_t new_performance_time); /* when running */
void SendRunMode(
run_mode mode);
virtual void SetRunMode(
run_mode mode); /* or, instead, SendRunMode() */
enum time_source_op {
B_TIMESOURCE_START = 1,
B_TIMESOURCE_STOP,
B_TIMESOURCE_STOP_IMMEDIATELY,
B_TIMESOURCE_SEEK
};
struct time_source_op_info {
time_source_op op;
int32 _reserved1;
bigtime_t real_time;
bigtime_t performance_time;
int32 _reserved2[6];
};
virtual status_t TimeSourceOp(
const time_source_op_info & op,
void * _reserved) = 0;
private:
friend class _BMediaRosterP;
friend class _BTimeSourceP;
friend class _SysTimeSource;
friend class BMediaNode;
friend class BMediaRoster;
friend class _ServerApp;
BTimeSource( /* private unimplemented */
const BTimeSource & clone);
BTimeSource & operator=(
const BTimeSource & clone);
/* Mmmh, stuffing! */
status_t _Reserved_TimeSource_0(void *); // TimeSourceOp()
virtual status_t _Reserved_TimeSource_1(void *);
virtual status_t _Reserved_TimeSource_2(void *);
virtual status_t _Reserved_TimeSource_3(void *);
virtual status_t _Reserved_TimeSource_4(void *);
virtual status_t _Reserved_TimeSource_5(void *);
bool fStopped;
area_id _mArea;
volatile _time_transmit_buf * _mBuf;
_BSlaveNodeStorageP * _mSlaveNodes;
area_id _mOrigArea;
uint32 _reserved_time_source_[11];
explicit BTimeSource(
media_node_id id);
void FinishCreate(); /* called by roster and/or server */
virtual status_t RemoveMe(BMediaNode * node);
virtual status_t AddMe(BMediaNode * node);
void DirectStart(bigtime_t at);
void DirectStop(bigtime_t at, bool immediate);
void DirectSeek(bigtime_t to, bigtime_t at);
void DirectSetRunMode(run_mode mode);
};
#endif /* _TIME_SOURCE_H */
+186
View File
@@ -0,0 +1,186 @@
/*******************************************************************************
/
/ File: TimedEventQueue.h
/
/ Description: A priority queue for holding media_timed_events.
/ Sorts by increasing time, so events near the front
/ of the queue are to occur earlier.
/
/ Copyright 1999, Be Incorporated, All Rights Reserved
/
*******************************************************************************/
#ifndef _TIMED_EVENT_QUEUE_H
#define _TIMED_EVENT_QUEUE_H
#include <MediaDefs.h>
struct _event_queue_imp;
struct media_timed_event {
media_timed_event();
media_timed_event(bigtime_t inTime, int32 inType);
media_timed_event(bigtime_t inTime, int32 inType,
void *inPointer, uint32 inCleanup);
media_timed_event(
bigtime_t inTime, int32 inType,
void *inPointer, uint32 inCleanup,
int32 inData, int64 inBigdata,
char *inUserData, size_t dataSize = 0);
media_timed_event(const media_timed_event & clone);
void operator=(const media_timed_event & clone);
~media_timed_event();
bigtime_t event_time;
int32 type;
void * pointer;
uint32 cleanup;
int32 data;
int64 bigdata;
char user_data[64];
uint32 _reserved_media_timed_event_[8];
};
_IMPEXP_MEDIA bool operator==(const media_timed_event & a, const media_timed_event & b);
_IMPEXP_MEDIA bool operator!=(const media_timed_event & a, const media_timed_event & b);
_IMPEXP_MEDIA bool operator<(const media_timed_event & a, const media_timed_event & b);
_IMPEXP_MEDIA bool operator>(const media_timed_event & a, const media_timed_event &b);
class BTimedEventQueue {
public:
enum event_type {
B_NO_EVENT = -1, // never push this type! it will fail
B_ANY_EVENT = 0, // never push this type! it will fail
B_START,
B_STOP,
B_SEEK,
B_WARP,
B_TIMER,
B_HANDLE_BUFFER,
B_DATA_STATUS,
B_HARDWARE,
B_PARAMETER,
/* user defined events above this value */
B_USER_EVENT = 0x4000
};
enum cleanup_flag {
B_NO_CLEANUP = 0,
B_RECYCLE_BUFFER, // recycle buffers handled by BTimedEventQueue
B_EXPIRE_TIMER, // call TimerExpired() on the event->data
B_USER_CLEANUP = 0x4000 // others go to the cleanup func
};
enum time_direction {
B_ALWAYS = -1,
B_BEFORE_TIME = 0,
B_AT_TIME,
B_AFTER_TIME
};
void * operator new(size_t s);
void operator delete(void * p, size_t s);
BTimedEventQueue();
virtual ~BTimedEventQueue();
status_t AddEvent(const media_timed_event &event);
status_t RemoveEvent(const media_timed_event *event);
status_t RemoveFirstEvent(media_timed_event * outEvent = NULL);
bool HasEvents() const;
int32 EventCount() const;
/* Accessors */
const media_timed_event * FirstEvent() const;
bigtime_t FirstEventTime() const;
const media_timed_event * LastEvent() const;
bigtime_t LastEventTime() const;
const media_timed_event * FindFirstMatch(
bigtime_t eventTime,
time_direction direction,
bool inclusive = true,
int32 eventType = B_ANY_EVENT);
/* queue manipulation */
/* call DoForEach to perform a function on each event in the */
/* queue. Return an appropriate status defining an action to take */
/* for that event. DoForEach is an atomic operation ensuring the */
/* consistency of the queue during the call. */
enum queue_action {
B_DONE = -1,
B_NO_ACTION = 0,
B_REMOVE_EVENT,
B_RESORT_QUEUE
};
typedef queue_action (*for_each_hook)(media_timed_event *event, void *context);
status_t DoForEach(
for_each_hook hook,
void *context,
bigtime_t eventTime = 0,
time_direction direction = B_ALWAYS,
bool inclusive = true,
int32 eventType = B_ANY_EVENT);
/* flushing events */
/* the cleanup hook is called when events are flushed from the queue */
/* and the cleanup is not B_NO_CLEANUP or B_RECYCLE_BUFFER */
typedef void (*cleanup_hook)(const media_timed_event *event, void * context);
void SetCleanupHook(cleanup_hook hook, void *context);
status_t FlushEvents(
bigtime_t eventTime,
time_direction direction,
bool inclusive = true,
int32 eventType = B_ANY_EVENT);
private:
BTimedEventQueue( //unimplemented
const BTimedEventQueue & other);
BTimedEventQueue &operator =( //unimplemented
const BTimedEventQueue & other);
/* hide actual queue implementation */
_event_queue_imp * fImp;
/* Mmmh, stuffing! */
virtual status_t _Reserved_BTimedEventQueue_0(void *, ...);
virtual status_t _Reserved_BTimedEventQueue_1(void *, ...);
virtual status_t _Reserved_BTimedEventQueue_2(void *, ...);
virtual status_t _Reserved_BTimedEventQueue_3(void *, ...);
virtual status_t _Reserved_BTimedEventQueue_4(void *, ...);
virtual status_t _Reserved_BTimedEventQueue_5(void *, ...);
virtual status_t _Reserved_BTimedEventQueue_6(void *, ...);
virtual status_t _Reserved_BTimedEventQueue_7(void *, ...);
virtual status_t _Reserved_BTimedEventQueue_8(void *, ...);
virtual status_t _Reserved_BTimedEventQueue_9(void *, ...);
virtual status_t _Reserved_BTimedEventQueue_10(void *, ...);
virtual status_t _Reserved_BTimedEventQueue_11(void *, ...);
virtual status_t _Reserved_BTimedEventQueue_12(void *, ...);
virtual status_t _Reserved_BTimedEventQueue_13(void *, ...);
virtual status_t _Reserved_BTimedEventQueue_14(void *, ...);
virtual status_t _Reserved_BTimedEventQueue_15(void *, ...);
virtual status_t _Reserved_BTimedEventQueue_16(void *, ...);
virtual status_t _Reserved_BTimedEventQueue_17(void *, ...);
virtual status_t _Reserved_BTimedEventQueue_18(void *, ...);
virtual status_t _Reserved_BTimedEventQueue_19(void *, ...);
virtual status_t _Reserved_BTimedEventQueue_20(void *, ...);
virtual status_t _Reserved_BTimedEventQueue_21(void *, ...);
virtual status_t _Reserved_BTimedEventQueue_22(void *, ...);
virtual status_t _Reserved_BTimedEventQueue_23(void *, ...);
uint32 _reserved_timed_event_queue_[6];
};
#endif
+89
View File
@@ -0,0 +1,89 @@
//-----------------------------------------------------------------------------
#ifndef _MIDI_H_
#define _MIDI_H_
#include <MidiDefs.h>
#include <OS.h>
class BMidiEvent;
class BList;
class BMidi {
public:
BMidi();
virtual ~BMidi();
virtual void NoteOff(uchar channel, uchar note,
uchar velocity, uint32 time = B_NOW);
virtual void NoteOn(uchar channel, uchar note,
uchar velocity, uint32 time = B_NOW);
virtual void KeyPressure(uchar channel, uchar note,
uchar pressure, uint32 time = B_NOW);
virtual void ControlChange(uchar channel, uchar control_number,
uchar control_value, uint32 time = B_NOW);
virtual void ProgramChange(uchar channel, uchar program_number,
uint32 time = B_NOW);
virtual void ChannelPressure(uchar channel, uchar pressure,
uint32 time = B_NOW);
virtual void PitchBend(uchar channel, uchar lsb,
uchar msb, uint32 time = B_NOW);
virtual void SystemExclusive(void * data, size_t data_length,
uint32 time = B_NOW);
virtual void SystemCommon(uchar status_byte, uchar data1,
uchar data2, uint32 time = B_NOW);
virtual void SystemRealTime(uchar status_byte, uint32 time = B_NOW);
virtual void TempoChange(int32 beats_per_minute, uint32 time = B_NOW);
virtual void AllNotesOff(bool just_channel = true, uint32 time = B_NOW);
virtual status_t Start();
virtual void Stop();
bool IsRunning() const;
void Connect(BMidi * to_object);
void Disconnect(BMidi * from_object);
bool IsConnected(BMidi * to_object) const;
BList * Connections() const;
void SnoozeUntil(uint32 time) const;
protected:
void SprayNoteOff(uchar channel, uchar note,
uchar velocity, uint32 time) const;
void SprayNoteOn(uchar channel, uchar note,
uchar velocity, uint32 time) const;
void SprayKeyPressure(uchar channel, uchar note,
uchar pressure, uint32 time) const;
void SprayControlChange(uchar channel, uchar control_number,
uchar control_value, uint32 time) const;
void SprayProgramChange(uchar channel, uchar program_number,
uint32 time) const;
void SprayChannelPressure(uchar channel, uchar pressure,
uint32 time) const;
void SprayPitchBend(uchar channel, uchar lsb,
uchar msb, uint32 time) const;
void SpraySystemExclusive(void * data, size_t data_length,
uint32 time) const;
void SpraySystemCommon(uchar status_byte, uchar data1,
uchar data2, uint32 time) const;
void SpraySystemRealTime(uchar status_byte, uint32 time) const;
void SprayTempoChange(int32 beats_per_minute, uint32 time) const;
bool KeepRunning();
private:
virtual void Run();
void _Inflow();
void _SprayEvent(BMidiEvent *) const;
static int32 _RunThread(void * data);
static int32 _InflowThread(void * data);
private:
BList * _con_list;
thread_id _run_thread_id;
thread_id _inflow_thread_id;
port_id _inflow_port;
bool _is_running;
bool _is_inflowing;
bool _keep_running;
};
#endif //_MIDI_H_
+248
View File
@@ -0,0 +1,248 @@
//-----------------------------------------------------------------------------
#ifndef _MIDI_DEFS_H_
#define _MIDI_DEFS_H_
#include <OS.h>
#include <Errors.h>
#define B_NOW ((uint32)(system_time()/1000))
#define B_SYNTH_DIRECTORY B_BEOS_ETC_DIRECTORY
#define B_BIG_SYNTH_FILE "synth/big_synth.sy"
#define B_LITTLE_SYNTH_FILE "synth/little_synth.sy"
typedef enum synth_mode {
B_NO_SYNTH,
B_BIG_SYNTH,
B_LITTLE_SYNTH,
B_DEFAULT_SYNTH,
B_SAMPLES_ONLY,
} synth_mode;
enum {
B_BAD_INSTRUMENT = B_MIDI_ERROR_BASE + 0x100,
B_BAD_MIDI_DATA,
B_ALREADY_PAUSED,
B_ALREADY_RESUMED,
B_NO_SONG_PLAYING,
B_TOO_MANY_SONGS_PLAYING,
};
#ifndef uchar
typedef unsigned char uchar;
#endif
#ifndef _MIDI_CONSTANTS_
#define _MIDI_CONSTANTS_
const uchar B_NOTE_OFF = 0x80;
const uchar B_NOTE_ON = 0x90;
const uchar B_KEY_PRESSURE = 0xa0;
const uchar B_CONTROL_CHANGE = 0xb0;
const uchar B_PROGRAM_CHANGE = 0xc0;
const uchar B_CHANNEL_PRESSURE = 0xd0;
const uchar B_PITCH_BEND = 0xe0;
const uchar B_SYS_EX_START = 0xf0;
const uchar B_MIDI_TIME_CODE = 0xf1;
const uchar B_SONG_POSITION = 0xf2;
const uchar B_SONG_SELECT = 0xf3;
const uchar B_CABLE_MESSAGE = 0xf5;
const uchar B_TUNE_REQUEST = 0xf6;
const uchar B_SYS_EX_END = 0xf7;
const uchar B_TIMING_CLOCK = 0xf8;
const uchar B_START = 0xfa;
const uchar B_CONTINUE = 0xfb;
const uchar B_STOP = 0xfc;
const uchar B_ACTIVE_SENSING = 0xfe;
const uchar B_SYSTEM_RESET = 0xff;
const uchar B_MODULATION = 0x01;
const uchar B_BREATH_CONTROLLER = 0x02;
const uchar B_FOOT_CONTROLLER = 0x04;
const uchar B_PORTAMENTO_TIME = 0x05;
const uchar B_DATA_ENTRY = 0x06;
const uchar B_MAIN_VOLUME = 0x07;
const uchar B_MIDI_BALANCE = 0x08;
const uchar B_PAN = 0x0a;
const uchar B_EXPRESSION_CTRL = 0x0b;
const uchar B_GENERAL_CTRL_1 = 0x10;
const uchar B_GENERAL_CTRL_2 = 0x11;
const uchar B_GENERAL_CTRL_3 = 0x12;
const uchar B_GENERAL_CTRL_4 = 0x13;
const uchar B_SUSTAIN_PEDAL = 0x40;
const uchar B_PORTAMENTO = 0x41;
const uchar B_SOSTENUTO = 0x42;
const uchar B_SOFT_PEDAL = 0x43;
const uchar B_HOLD_2 = 0x45;
const uchar B_GENERAL_CTRL_5 = 0x50;
const uchar B_GENERAL_CTRL_6 = 0x51;
const uchar B_GENERAL_CTRL_7 = 0x52;
const uchar B_GENERAL_CTRL_8 = 0x53;
const uchar B_EFFECTS_DEPTH = 0x5b;
const uchar B_TREMOLO_DEPTH = 0x5c;
const uchar B_CHORUS_DEPTH = 0x5d;
const uchar B_CELESTE_DEPTH = 0x5e;
const uchar B_PHASER_DEPTH = 0x5f;
const uchar B_DATA_INCREMENT = 0x60;
const uchar B_DATA_DECREMENT = 0x61;
const uchar B_RESET_ALL_CONTROLLERS = 0x79;
const uchar B_LOCAL_CONTROL = 0x7a;
const uchar B_ALL_NOTES_OFF = 0x7b;
const uchar B_OMNI_MODE_OFF = 0x7c;
const uchar B_OMNI_MODE_ON = 0x7d;
const uchar B_MONO_MODE_ON = 0x7e;
const uchar B_POLY_MODE_ON = 0x7f;
const uchar B_TEMPO_CHANGE = 0x51;
#endif
typedef enum midi_axe {
B_ACOUSTIC_GRAND=0,
B_BRIGHT_GRAND,
B_ELECTRIC_GRAND,
B_HONKY_TONK,
B_ELECTRIC_PIANO_1,
B_ELECTRIC_PIANO_2,
B_HARPSICHORD,
B_CLAVICHORD,
B_CELESTA,
B_GLOCKENSPIEL,
B_MUSIC_BOX,
B_VIBRAPHONE,
B_MARIMBA,
B_XYLOPHONE,
B_TUBULAR_BELLS,
B_DULCIMER,
B_DRAWBAR_ORGAN,
B_PERCUSSIVE_ORGAN,
B_ROCK_ORGAN,
B_CHURCH_ORGAN,
B_REED_ORGAN,
B_ACCORDION,
B_HARMONICA,
B_TANGO_ACCORDION,
B_ACOUSTIC_GUITAR_NYLON,
B_ACOUSTIC_GUITAR_STEEL,
B_ELECTRIC_GUITAR_JAZZ,
B_ELECTRIC_GUITAR_CLEAN,
B_ELECTRIC_GUITAR_MUTED,
B_OVERDRIVEN_GUITAR,
B_DISTORTION_GUITAR,
B_GUITAR_HARMONICS,
B_ACOUSTIC_BASS,
B_ELECTRIC_BASS_FINGER,
B_ELECTRIC_BASS_PICK,
B_FRETLESS_BASS,
B_SLAP_BASS_1,
B_SLAP_BASS_2,
B_SYNTH_BASS_1,
B_SYNTH_BASS_2,
B_VIOLIN,
B_VIOLA,
B_CELLO,
B_CONTRABASS,
B_TREMOLO_STRINGS,
B_PIZZICATO_STRINGS,
B_ORCHESTRAL_STRINGS,
B_TIMPANI,
B_STRING_ENSEMBLE_1,
B_STRING_ENSEMBLE_2,
B_SYNTH_STRINGS_1,
B_SYNTH_STRINGS_2,
B_VOICE_AAH,
B_VOICE_OOH,
B_SYNTH_VOICE,
B_ORCHESTRA_HIT,
B_TRUMPET,
B_TROMBONE,
B_TUBA,
B_MUTED_TRUMPET,
B_FRENCH_HORN,
B_BRASS_SECTION,
B_SYNTH_BRASS_1,
B_SYNTH_BRASS_2,
B_SOPRANO_SAX,
B_ALTO_SAX,
B_TENOR_SAX,
B_BARITONE_SAX,
B_OBOE,
B_ENGLISH_HORN,
B_BASSOON,
B_CLARINET,
B_PICCOLO,
B_FLUTE,
B_RECORDER,
B_PAN_FLUTE,
B_BLOWN_BOTTLE,
B_SHAKUHACHI,
B_WHISTLE,
B_OCARINA,
B_LEAD_1,
B_SQUARE_WAVE = B_LEAD_1,
B_LEAD_2,
B_SAWTOOTH_WAVE = B_LEAD_2,
B_LEAD_3,
B_CALLIOPE = B_LEAD_3,
B_LEAD_4,
B_CHIFF = B_LEAD_4,
B_LEAD_5,
B_CHARANG = B_LEAD_5,
B_LEAD_6,
B_VOICE = B_LEAD_6,
B_LEAD_7,
B_FIFTHS = B_LEAD_7,
B_LEAD_8,
B_BASS_LEAD = B_LEAD_8,
B_PAD_1,
B_NEW_AGE = B_PAD_1,
B_PAD_2,
B_WARM = B_PAD_2,
B_PAD_3,
B_POLYSYNTH = B_PAD_3,
B_PAD_4,
B_CHOIR = B_PAD_4,
B_PAD_5,
B_BOWED = B_PAD_5,
B_PAD_6,
B_METALLIC = B_PAD_6,
B_PAD_7,
B_HALO = B_PAD_7,
B_PAD_8,
B_SWEEP = B_PAD_8,
B_FX_1,
B_FX_2,
B_FX_3,
B_FX_4,
B_FX_5,
B_FX_6,
B_FX_7,
B_FX_8,
B_SITAR,
B_BANJO,
B_SHAMISEN,
B_KOTO,
B_KALIMBA,
B_BAGPIPE,
B_FIDDLE,
B_SHANAI,
B_TINKLE_BELL,
B_AGOGO,
B_STEEL_DRUMS,
B_WOODBLOCK,
B_TAIKO_DRUMS,
B_MELODIC_TOM,
B_SYNTH_DRUM,
B_REVERSE_CYMBAL,
B_FRET_NOISE,
B_BREATH_NOISE,
B_SEASHORE,
B_BIRD_TWEET,
B_TELEPHONE,
B_HELICOPTER,
B_APPLAUSE,
B_GUNSHOT
} midi_axe;
#endif //_MIDI_DEFS_H_
+76
View File
@@ -0,0 +1,76 @@
//-----------------------------------------------------------------------------
#ifndef _MIDI_STORE_H_
#define _MIDI_STORE_H_
#include <Midi.h>
#include <List.h>
struct entry_ref;
class BMidiEvent;
class BFile;
class BMidiStore : public BMidi {
public:
BMidiStore();
virtual ~BMidiStore();
virtual void NoteOff(uchar channel, uchar note,
uchar velocity, uint32 time = B_NOW);
virtual void NoteOn(uchar channel, uchar note,
uchar velocity, uint32 time = B_NOW);
virtual void KeyPressure(uchar channel, uchar note,
uchar pressure, uint32 time = B_NOW);
virtual void ControlChange(uchar channel, uchar control_number,
uchar control_value, uint32 time = B_NOW);
virtual void ProgramChange(uchar channel, uchar program_number,
uint32 time = B_NOW);
virtual void ChannelPressure(uchar channel, uchar pressure,
uint32 time = B_NOW);
virtual void PitchBend(uchar channel, uchar lsb,
uchar msb, uint32 time = B_NOW);
virtual void SystemExclusive(void * data, size_t data_length,
uint32 time = B_NOW);
virtual void SystemCommon(uchar status_byte, uchar data1,
uchar data2, uint32 time = B_NOW);
virtual void SystemRealTime(uchar status_byte, uint32 time = B_NOW);
virtual void TempoChange(int32 beats_per_minute, uint32 time = B_NOW);
virtual void AllNotesOff(bool just_channel = true, uint32 time = B_NOW);
status_t Import(const entry_ref * ref);
status_t Export(const entry_ref * ref, int32 format);
void SortEvents(bool force = false);
uint32 CountEvents() const;
uint32 CurrentEvent() const;
void SetCurrentEvent(uint32 event_number);
uint32 DeltaOfEvent(uint32 event_number) const;
uint32 EventAtDelta(uint32 time) const;
uint32 BeginTime() const;
void SetTempo(int32 beats_per_minute);
int32 Tempo() const;
private:
virtual void Run();
void _RunThread();
uint8* _DecodeTrack(uint8 *);
void _DecodeFormat0Tracks(uint8 *, uint16, uint32);
void _DecodeFormat1Tracks(uint8 *, uint16, uint32);
void _DecodeFormat2Tracks(uint8 *, uint16, uint32);
void _EncodeFormat0Tracks(uint8 *);
void _EncodeFormat1Tracks(uint8 *);
void _EncodeFormat2Tracks(uint8 *);
void _ReadEvent(uint8, uint8 **, uint8 *, BMidiEvent *);
void _WriteEvent(BMidiEvent *);
uint32 _ReadVarLength(uint8 **, uint8 *);
void _WriteVarLength(uint32);
static int _CompareEvents(const void *, const void *);
private:
BList * _evt_list;
uint32 _tempo;
uint32 _cur_evt;
uint32 _start_time;
uint32 _ticks_per_beat;
};
#endif _MIDI_STORE_H_
+43
View File
@@ -0,0 +1,43 @@
//-----------------------------------------------------------------------------
#ifndef _MIDI_TEXT_H_
#define _MIDI_TEXT_H_
#include <Midi.h>
class BMidiText : public BMidi {
public:
BMidiText();
virtual ~BMidiText();
virtual void NoteOff(uchar channel, uchar note,
uchar velocity, uint32 time = B_NOW);
virtual void NoteOn(uchar channel, uchar note,
uchar velocity, uint32 time = B_NOW);
virtual void KeyPressure(uchar channel, uchar note,
uchar pressure, uint32 time = B_NOW);
virtual void ControlChange(uchar channel, uchar control_number,
uchar control_value, uint32 time = B_NOW);
virtual void ProgramChange(uchar channel, uchar program_number,
uint32 time = B_NOW);
virtual void ChannelPressure(uchar channel, uchar pressure,
uint32 time = B_NOW);
virtual void PitchBend(uchar channel, uchar lsb,
uchar msb, uint32 time = B_NOW);
virtual void SystemExclusive(void * data, size_t data_length,
uint32 time = B_NOW);
virtual void SystemCommon(uchar status_byte, uchar data1,
uchar data2, uint32 time = B_NOW);
virtual void SystemRealTime(uchar status_byte, uint32 time = B_NOW);
virtual void TempoChange(int32 beats_per_minute, uint32 time = B_NOW);
virtual void AllNotesOff(bool just_channel = true, uint32 time = B_NOW);
void ResetTimer(bool start = false);
private:
int32 _start_time;
private:
void _PrintTime();
};
#endif _MIDI_TEXT_H_
+109
View File
@@ -0,0 +1,109 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//---------------------------------------------------------------------
/*!
\file Directory.h
BDirectory interface declaration.
*/
#ifndef __sk_directory_h__
#define __sk_directory_h__
#include <Node.h>
#include <EntryList.h>
#include <StorageDefs.h>
#include <StorageDefs.Private.h>
#ifdef USE_OPENBEOS_NAMESPACE
namespace OpenBeOS {
#endif
class BSymLink;
/*!
\class BDirectory
\brief A directory in the filesystem
Provides an interface for manipulating directories and their contents.
\author <a href='mailto:[email protected]'>Ingo Weinhold</a>
\author <a href="mailto:[email protected]">Tyler Dauwalder</a>
\version 0.0.0
*/
class BDirectory : public BNode, public BEntryList {
public:
BDirectory();
BDirectory(const BDirectory &dir);
BDirectory(const entry_ref *ref);
BDirectory(const node_ref *nref);
BDirectory(const BEntry *entry);
BDirectory(const char *path);
BDirectory(const BDirectory *dir, const char *path);
virtual ~BDirectory();
status_t SetTo(const entry_ref *ref);
status_t SetTo(const node_ref *nref);
status_t SetTo(const BEntry *entry);
status_t SetTo(const char *path);
status_t SetTo(const BDirectory *dir, const char *path);
status_t GetEntry(BEntry *entry) const;
bool IsRootDirectory() const;
status_t FindEntry(const char *path, BEntry *entry,
bool traverse = false) const;
bool Contains(const char *path, int32 nodeFlags = B_ANY_NODE) const;
bool Contains(const BEntry *entry, int32 nodeFlags = B_ANY_NODE) const;
status_t GetStatFor(const char *path, struct stat *st) const;
virtual status_t GetNextEntry(BEntry *entry, bool traverse = false);
virtual status_t GetNextRef(entry_ref *ref);
virtual int32 GetNextDirents(dirent *buf, size_t bufSize,
int32 count = INT_MAX);
virtual status_t Rewind();
virtual int32 CountEntries();
status_t CreateDirectory(const char *path, BDirectory *dir);
status_t CreateFile(const char *path, BFile *file,
bool failIfExists = false);
status_t CreateSymLink(const char *path, const char *linkToPath,
BSymLink *link);
BDirectory &operator=(const BDirectory &dir);
private:
virtual void _ReservedDirectory1();
virtual void _ReservedDirectory2();
virtual void _ReservedDirectory3();
virtual void _ReservedDirectory4();
virtual void _ReservedDirectory5();
virtual void _ReservedDirectory6();
private:
virtual void close_fd();
StorageKit::FileDescriptor get_fd() const;
private:
uint32 _reservedData[7];
StorageKit::FileDescriptor fDirFd;
friend class BEntry;
};
// C functions
status_t create_directory(const char *path, mode_t mode);
#ifdef USE_OPENBEOS_NAMESPACE
}; // namespace OpenBeOS
#endif
#endif // __sk_directory_h__
+120
View File
@@ -0,0 +1,120 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//---------------------------------------------------------------------
/*!
\file Entry.h
BEntry and entry_ref interface declarations.
*/
#ifndef __sk_entry_h__
#define __sk_entry_h__
#include <sys/types.h>
#include <sys/stat.h>
#include <SupportDefs.h>
#include <Statable.h>
#include <StorageDefs.Private.h>
#ifdef USE_OPENBEOS_NAMESPACE
namespace OpenBeOS {
#endif
class BDirectory;
class BPath;
struct entry_ref {
entry_ref();
entry_ref(dev_t dev, ino_t dir, const char *name);
entry_ref(const entry_ref &ref);
~entry_ref();
status_t set_name(const char *name);
bool operator==(const entry_ref &ref) const;
bool operator!=(const entry_ref &ref) const;
entry_ref &operator=(const entry_ref &ref);
dev_t device;
ino_t directory;
char *name;
};
class BEntry : public BStatable {
public:
BEntry();
BEntry(const BDirectory *dir, const char *path, bool traverse = false);
BEntry(const entry_ref *ref, bool traverse = false);
BEntry(const char *path, bool traverse = false);
BEntry(const BEntry &entry);
virtual ~BEntry();
status_t InitCheck() const;
bool Exists() const;
virtual status_t GetStat(struct stat *st) const;
status_t SetTo(const BDirectory *dir, const char *path,
bool traverse = false);
status_t SetTo(const entry_ref *ref, bool traverse = false);
status_t SetTo(const char *path, bool traverse = false);
void Unset();
status_t GetRef(entry_ref *ref) const;
status_t GetPath(BPath *path) const;
status_t GetParent(BEntry *entry) const;
status_t GetParent(BDirectory *dir) const;
status_t GetName(char *buffer) const;
status_t Rename(const char *path, bool clobber = false);
status_t MoveTo(BDirectory *dir, const char *path = NULL,
bool clobber = false);
status_t Remove();
bool operator==(const BEntry &item) const;
bool operator!=(const BEntry &item) const;
BEntry &operator=(const BEntry &item);
private:
virtual void _PennyEntry1();
virtual void _PennyEntry2();
virtual void _PennyEntry3();
virtual void _PennyEntry4();
virtual void _PennyEntry5();
virtual void _PennyEntry6();
/*! Currently unused. */
uint32 _pennyData[4];
/*! BEntry implementation of BStatable::set_stat() */
virtual status_t set_stat(struct stat &st, uint32 what);
status_t set(StorageKit::FileDescriptor dir, const char *path,
bool traverse);
/*! File descriptor for the entry's parent directory. */
StorageKit::FileDescriptor fDirFd;
/*! Leaf name of the entry. */
char *fName;
/*! The object's initialization status. */
status_t fCStatus;
status_t set_name(const char *name);
void Dump(const char *name = NULL);
};
// C functions
status_t get_ref_for_path(const char *path, entry_ref *ref);
bool operator<(const entry_ref &a, const entry_ref &b);
#ifdef USE_OPENBEOS_NAMESPACE
}; // namespace OpenBeOS
#endif
#endif // __sk_entry_h__
+60
View File
@@ -0,0 +1,60 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//---------------------------------------------------------------------
/*!
\file EntryList.h
BEntryList interface declaration.
*/
#ifndef __sk_entry_list_h__
#define __sk_entry_list_h__
#include <dirent.h>
#include <SupportDefs.h>
#ifdef USE_OPENBEOS_NAMESPACE
namespace OpenBeOS {
#endif
// Forward declarations
class BEntry;
struct entry_ref;
//! Interface for iterating through a list of filesystem entries
/*! Defines a general interface for iterating through a list of entries (i.e.
files in a folder
@author <a href='mailto:[email protected]'>Tyler Dauwalder</a>
@author Be Inc.
@version 0.0.0
*/
class BEntryList {
public:
BEntryList();
virtual ~BEntryList();
virtual status_t GetNextEntry(BEntry *entry, bool traverse = false) = 0;
virtual status_t GetNextRef(entry_ref *ref) = 0;
virtual int32 GetNextDirents(struct dirent *buf, size_t length,
int32 count = INT_MAX) = 0;
virtual status_t Rewind() = 0;
virtual int32 CountEntries() = 0;
private:
virtual void _ReservedEntryList1();
virtual void _ReservedEntryList2();
virtual void _ReservedEntryList3();
virtual void _ReservedEntryList4();
virtual void _ReservedEntryList5();
virtual void _ReservedEntryList6();
virtual void _ReservedEntryList7();
virtual void _ReservedEntryList8();
};
#ifdef USE_OPENBEOS_NAMESPACE
}; // namespace OpenBeOS
#endif
#endif // __sk_entry_list_h__
+85
View File
@@ -0,0 +1,85 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//---------------------------------------------------------------------
/*!
\file File.h
BFile interface declaration.
*/
#ifndef __sk_file_h__
#define __sk_file_h__
#include <DataIO.h>
#include <Node.h>
#include <StorageDefs.Private.h>
#ifdef USE_OPENBEOS_NAMESPACE
namespace OpenBeOS {
#endif
/*!
\class BFile
\brief BFile is a wrapper class for common operations on files providing
access to the file's content data and its attributes.
A BFile represents a file in some file system. It implements the
BPositionIO interface and thus the methods to read from and write to the
file, and is derived of BNode to provide access to the file's attributes.
\author <a href='mailto:[email protected]'>Ingo Weinhold</a>
\version 0.0.0
*/
class BFile : public BNode, public BPositionIO {
public:
BFile();
BFile(const BFile &file);
BFile(const entry_ref *ref, uint32 openMode);
BFile(const BEntry *entry, uint32 openMode);
BFile(const char *path, uint32 openMode);
BFile(BDirectory *dir, const char *path, uint32 openMode);
virtual ~BFile();
status_t SetTo(const entry_ref *ref, uint32 openMode);
status_t SetTo(const BEntry *entry, uint32 openMode);
status_t SetTo(const char *path, uint32 openMode);
status_t SetTo(const BDirectory *dir, const char *path, uint32 openMode);
bool IsReadable() const;
bool IsWritable() const;
virtual ssize_t Read(void *buffer, size_t size);
virtual ssize_t ReadAt(off_t location, void *buffer, size_t size);
virtual ssize_t Write(const void *buffer, size_t size);
virtual ssize_t WriteAt(off_t location, const void *buffer, size_t size);
virtual off_t Seek(off_t offset, uint32 seekMode);
virtual off_t Position() const;
virtual status_t SetSize(off_t size);
BFile &operator=(const BFile &file);
private:
virtual void _ReservedFile1();
virtual void _ReservedFile2();
virtual void _ReservedFile3();
virtual void _ReservedFile4();
virtual void _ReservedFile5();
virtual void _ReservedFile6();
uint32 _reservedData[8];
private:
StorageKit::FileDescriptor get_fd() const;
private:
//! The file's open mode.
uint32 fMode;
};
#ifdef USE_OPENBEOS_NAMESPACE
}; // namespace OpenBeOS
#endif
#endif // __sk_file_h__
+135
View File
@@ -0,0 +1,135 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//---------------------------------------------------------------------
/*!
\file FindDirectory.h
Declarations of find_directory() functions and associated types.
*/
#ifndef __sk_find_directory_h__
#define __sk_find_directory_h__
#include <SupportDefs.h>
#ifdef USE_OPENBEOS_NAMESPACE
namespace OpenBeOS {
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
/* ---
Per volume directories. When asking for these
directories, a volume must be specified, or the call will assume
the boot volume.
--- */
B_DESKTOP_DIRECTORY = 0,
B_TRASH_DIRECTORY,
/* ---
BeOS directories. These are mostly accessed read-only.
--- */
B_BEOS_DIRECTORY = 1000,
B_BEOS_SYSTEM_DIRECTORY,
B_BEOS_ADDONS_DIRECTORY,
B_BEOS_BOOT_DIRECTORY,
B_BEOS_FONTS_DIRECTORY,
B_BEOS_LIB_DIRECTORY,
B_BEOS_SERVERS_DIRECTORY,
B_BEOS_APPS_DIRECTORY,
B_BEOS_BIN_DIRECTORY,
B_BEOS_ETC_DIRECTORY,
B_BEOS_DOCUMENTATION_DIRECTORY,
B_BEOS_PREFERENCES_DIRECTORY,
B_BEOS_TRANSLATORS_DIRECTORY,
B_BEOS_MEDIA_NODES_DIRECTORY,
B_BEOS_SOUNDS_DIRECTORY,
/* ---
Common directories, shared among all users.
--- */
B_COMMON_DIRECTORY = 2000,
B_COMMON_SYSTEM_DIRECTORY,
B_COMMON_ADDONS_DIRECTORY,
B_COMMON_BOOT_DIRECTORY,
B_COMMON_FONTS_DIRECTORY,
B_COMMON_LIB_DIRECTORY,
B_COMMON_SERVERS_DIRECTORY,
B_COMMON_BIN_DIRECTORY,
B_COMMON_ETC_DIRECTORY,
B_COMMON_DOCUMENTATION_DIRECTORY,
B_COMMON_SETTINGS_DIRECTORY,
B_COMMON_DEVELOP_DIRECTORY,
B_COMMON_LOG_DIRECTORY,
B_COMMON_SPOOL_DIRECTORY,
B_COMMON_TEMP_DIRECTORY,
B_COMMON_VAR_DIRECTORY,
B_COMMON_TRANSLATORS_DIRECTORY,
B_COMMON_MEDIA_NODES_DIRECTORY,
B_COMMON_SOUNDS_DIRECTORY,
/* ---
User directories. These are interpreted in the context
of the user making the find_directory call.
--- */
B_USER_DIRECTORY = 3000,
B_USER_CONFIG_DIRECTORY,
B_USER_ADDONS_DIRECTORY,
B_USER_BOOT_DIRECTORY,
B_USER_FONTS_DIRECTORY,
B_USER_LIB_DIRECTORY,
B_USER_SETTINGS_DIRECTORY,
B_USER_DESKBAR_DIRECTORY,
B_USER_PRINTERS_DIRECTORY,
B_USER_TRANSLATORS_DIRECTORY,
B_USER_MEDIA_NODES_DIRECTORY,
B_USER_SOUNDS_DIRECTORY,
/* ---
Global directories.
--- */
B_APPS_DIRECTORY = 4000,
B_PREFERENCES_DIRECTORY,
B_UTILITIES_DIRECTORY
} directory_which;
/* ---
The C interface
--- */
status_t find_directory(directory_which which, dev_t volume, bool createIt,
char *pathString, int32 length);
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
class BVolume;
class BPath;
/* ---
C++ interface
--- */
status_t find_directory(directory_which which, BPath *path,
bool createIt = false, BVolume *volume = NULL);
#endif
#ifdef USE_OPENBEOS_NAMESPACE
}; // namespace OpenBeOS
#endif
#endif // __sk_find_directory_h__

Some files were not shown because too many files have changed in this diff Show More