Shaka Packager SDK
udp_file.h
1 // Copyright 2014 Google Inc. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file or at
5 // https://developers.google.com/open-source/licenses/bsd
6 
7 #ifndef MEDIA_FILE_UDP_FILE_H_
8 #define MEDIA_FILE_UDP_FILE_H_
9 
10 #include <stdint.h>
11 
12 #include <string>
13 
14 #include "packager/base/compiler_specific.h"
15 #include "packager/file/file.h"
16 
17 #if defined(OS_WIN)
18 #include <winsock2.h>
19 #else
20 typedef int SOCKET;
21 #endif // defined(OS_WIN)
22 
23 namespace shaka {
24 
26 class UdpFile : public File {
27  public:
30  explicit UdpFile(const char* address_and_port);
31 
34  bool Close() override;
35  int64_t Read(void* buffer, uint64_t length) override;
36  int64_t Write(const void* buffer, uint64_t length) override;
37  int64_t Size() override;
38  bool Flush() override;
39  bool Seek(uint64_t position) override;
40  bool Tell(uint64_t* position) override;
42 
43  protected:
44  ~UdpFile() override;
45 
46  bool Open() override;
47 
48  private:
49  SOCKET socket_;
50 #if defined(OS_WIN)
51  // For Winsock in Windows.
52  bool wsa_started_ = false;
53 #endif // defined(OS_WIN)
54 
55  DISALLOW_COPY_AND_ASSIGN(UdpFile);
56 };
57 
58 } // namespace shaka
59 
60 #endif // MEDIA_FILE_UDP_FILE_H_
shaka::UdpFile::Flush
bool Flush() override
Definition: udp_file.cc:105
shaka::UdpFile::UdpFile
UdpFile(const char *address_and_port)
Definition: udp_file.cc:58
shaka
All the methods that are virtual are virtual for mocking.
Definition: gflags_hex_bytes.cc:11
shaka::UdpFile::Open
bool Open() override
Internal open. Should not be used directly.
Definition: udp_file.cc:143
shaka::UdpFile
Implements UdpFile, which receives UDP unicast and multicast streams.
Definition: udp_file.h:26
shaka::UdpFile::Close
bool Close() override
Definition: udp_file.cc:63
shaka::UdpFile::Seek
bool Seek(uint64_t position) override
Definition: udp_file.cc:110
shaka::UdpFile::Size
int64_t Size() override
Definition: udp_file.cc:98
shaka::File
Define an abstract file interface.
Definition: file.h:28
shaka::UdpFile::Tell
bool Tell(uint64_t *position) override
Definition: udp_file.cc:115
shaka::UdpFile::Read
int64_t Read(void *buffer, uint64_t length) override
Definition: udp_file.cc:76
shaka::UdpFile::Write
int64_t Write(const void *buffer, uint64_t length) override
Definition: udp_file.cc:93