Shaka Packager SDK
udp_file.h
1 // Copyright 2014 Google LLC. 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 <cstdint>
11 #include <string>
12 
13 #if defined(OS_WIN)
14 #include <windows.h>
15 #include <winsock2.h>
16 #else
17 typedef int SOCKET;
18 #endif // defined(OS_WIN)
19 
20 #include <packager/file.h>
21 #include <packager/macros/classes.h>
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  void CloseForWriting() override;
38  int64_t Size() override;
39  bool Flush() override;
40  bool Seek(uint64_t position) override;
41  bool Tell(uint64_t* position) override;
43 
44  protected:
45  ~UdpFile() override;
46 
47  bool Open() override;
48 
49  private:
50  SOCKET socket_;
51 #if defined(OS_WIN)
52  // For Winsock in Windows.
53  bool wsa_started_ = false;
54 #endif // defined(OS_WIN)
55 
56  DISALLOW_COPY_AND_ASSIGN(UdpFile);
57 };
58 
59 } // namespace shaka
60 
61 #endif // MEDIA_FILE_UDP_FILE_H_
Implements UdpFile, which receives UDP unicast and multicast streams.
Definition: udp_file.h:26
UdpFile(const char *address_and_port)
Definition: udp_file.cc:58
All the methods that are virtual are virtual for mocking.
Definition: crypto_flags.cc:66