sipxmedialib  Version 3.3
StreamFileDataSource.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2006 SIPez LLC.
3 // Licensed to SIPfoundry under a Contributor Agreement.
4 //
5 // Copyright (C) 2004-2006 SIPfoundry Inc.
6 // Licensed by SIPfoundry under the LGPL license.
7 //
8 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
9 // Licensed to SIPfoundry under a Contributor Agreement.
10 //
11 // $$
13 
14 #ifndef DISABLE_STREAM_PLAYER // [
15 
16 #ifndef _StreamFileDataSource_h_
17 #define _StreamFileDataSource_h_
18 
19 // SYSTEM INCLUDES
20 // APPLICATION INCLUDES
21 #include "mp/StreamDataSource.h"
22 #include "net/Url.h"
23 #include "os/OsDefs.h"
24 #include "os/OsStatus.h"
25 #include "os/OsFS.h"
26 #include "os/OsMutex.h"
27 
28 // DEFINES
29 // MACROS
30 // EXTERNAL FUNCTIONS
31 // EXTERNAL VARIABLES
32 // CONSTANTS
33 // STRUCTS
34 // TYPEDEFS
35 // FORWARD DECLARATIONS
36 
37 //:Defines a stream data source built ontop of a OsFile
39 {
40 /* //////////////////////////// PUBLIC //////////////////////////////////// */
41 public:
42 
43 /* ============================ CREATORS ================================== */
45 
46  StreamFileDataSource(Url url, int iFlags);
47  //:Default constructor
48 
49 
50  virtual
52  //:Destructor
53 
55 
56 /* ============================ MANIPULATORS ============================== */
58 
59  virtual OsStatus open() ;
60  //:Opens the data source
61 
62  virtual OsStatus close() ;
63  //:Closes the data source
64 
65  virtual OsStatus destroyAndDelete() ;
66  //:Destroys and deletes the data source object
67 
68  virtual OsStatus read(char *szBuffer, int iLength, int& iLengthRead) ;
69  //:Reads iLength bytes of data from the data source and places the
70  //:data into the passed szBuffer buffer.
71  //
75 
76  virtual OsStatus peek(char* szBuffer, int iLength, int& iLengthRead) ;
77  //:Identical to read, except the stream pointer is not advanced.
78  //
82 
83  virtual OsStatus seek(unsigned int iLocation) ;
84  //:Moves the stream pointer to the an absolute location.
85  //
87 
89 
90 /* ============================ ACCESSORS ================================= */
92 
93 
94  virtual OsStatus getLength(int& iLength) ;
95  //:Gets the length of the stream (if available)
96 
97  virtual OsStatus getPosition(int& iPosition) ;
98  //:Gets the current position within the stream.
99 
100  virtual OsStatus toString(UtlString& string) ;
101  //:Renders a string describing this data source.
102  // This is often used for debugging purposes.
103 
105 
106 /* ============================ INQUIRY =================================== */
108 
109 
111 
112 /* //////////////////////////// PROTECTED ///////////////////////////////// */
113 protected:
114 
115  StreamFileDataSource(const StreamFileDataSource& rStreamFileDataSource);
116  //:Copy constructor
117 
119  //:Assignment operator
120 
121 
122 /* //////////////////////////// PRIVATE /////////////////////////////////// */
123 private:
124  Url mUrl ; // File Url source
125  OsFile* mpFile ; // Actual File data source
126 
127  OsMutex mFileGuard; // Guard closing/touch file from multiple threads
128 };
129 
130 /* ============================ INLINE METHODS ============================ */
131 
132 #endif // _StreamFileDataSource_h_
133 
134 #endif // DISABLE_STREAM_PLAYER ]
virtual OsStatus destroyAndDelete()
Destroys and deletes the data source object.
Definition: StreamFileDataSource.cpp:106
virtual OsStatus read(char *szBuffer, int iLength, int &iLengthRead)
Definition: StreamFileDataSource.cpp:118
StreamFileDataSource(Url url, int iFlags)
Definition: StreamFileDataSource.cpp:30
An abstraction definition of a stream data source.
Definition: StreamDataSource.h:47
Definition: StreamFileDataSource.h:38
virtual OsStatus peek(char *szBuffer, int iLength, int &iLengthRead)
Definition: StreamFileDataSource.cpp:139
virtual OsStatus getPosition(int &iPosition)
Gets the current position within the stream.
Definition: StreamFileDataSource.cpp:200
virtual OsStatus seek(unsigned int iLocation)
Definition: StreamFileDataSource.cpp:164
OsMutex mFileGuard
Definition: StreamFileDataSource.h:127
virtual OsStatus getLength(int &iLength)
Gets the length of the stream (if available)
Definition: StreamFileDataSource.cpp:185
virtual ~StreamFileDataSource()
Definition: StreamFileDataSource.cpp:39
virtual OsStatus open()
Opens the data source.
Definition: StreamFileDataSource.cpp:53
StreamFileDataSource & operator=(const StreamFileDataSource &rhs)
Definition: StreamFileDataSource.cpp:242
Url mUrl
Definition: StreamFileDataSource.h:124
virtual OsStatus toString(UtlString &string)
Renders a string describing this data source.
Definition: StreamFileDataSource.cpp:218
virtual OsStatus close()
Closes the data source.
Definition: StreamFileDataSource.cpp:90
OsFile * mpFile
Definition: StreamFileDataSource.h:125