TizenRT Public API  v2.0 M2
SocketOutputDataSource.h
Go to the documentation of this file.
1 /* ****************************************************************
2  *
3  * Copyright 2018 Samsung Electronics All Rights Reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  ******************************************************************/
18 
29 #ifndef __MEDIA_SOCKETOUTPUTDATASOURCE_H
30 #define __MEDIA_SOCKETOUTPUTDATASOURCE_H
31 
32 #include <media/OutputDataSource.h>
33 
34 #ifndef CONFIG_NET
35 #error CONFIG_NET should be turn on to use SocketOutputDataSource class.
36 #endif
37 
38 namespace media {
39 namespace stream {
47 {
48 public:
55  SocketOutputDataSource() = delete;
63  SocketOutputDataSource(const std::string& ipAddr, const uint16_t port);
74  SocketOutputDataSource(unsigned int channels, unsigned int sampleRate, audio_format_type_t pcmFormat, const std::string& ipAddr, const uint16_t port);
92  virtual ~SocketOutputDataSource();
93 
100  bool isPrepare() override;
107  bool open() override;
114  bool close() override;
115 
125  ssize_t write(unsigned char* buf, size_t size) override;
126 
127 private:
128  std::string mIpAddr;
129  uint16_t mPort;
130  int mSockFd;
131 };
132 } // namespace stream
133 } // namespace media
134 
135 #endif
136  // end of MEDIA group
virtual ~SocketOutputDataSource()
Deconstructs an empty SocketOutputDataSource.
bool close() override
Close the file.
ssize_t write(unsigned char *buf, size_t size) override
Puts the file data.
Media OutputDataSource APIs.
SocketOutputDataSource()=delete
Constructs an empty SocketOutputDataSource.
bool isPrepare() override
Whether file is ready to be write.
SocketOutputDataSource & operator=(const SocketOutputDataSource &source)
Operator= for SocketOutputDataSource.
bool open() override
Open the file.