Shaka Packager SDK
Loading...
Searching...
No Matches
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
12#if defined(OS_WIN)
13#include <windows.h>
14#include <winsock2.h>
15#else
16typedef int SOCKET;
17#endif // defined(OS_WIN)
18
19#include <packager/file.h>
20#include <packager/macros/classes.h>
21
22namespace shaka {
23
25class UdpFile : public File {
26 public:
29 explicit UdpFile(const char* address_and_port);
30
33 bool Close() override;
34 int64_t Read(void* buffer, uint64_t length) override;
35 int64_t Write(const void* buffer, uint64_t length) override;
36 void CloseForWriting() 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_
Implements UdpFile, which receives UDP unicast and multicast streams.
Definition udp_file.h:25
All the methods that are virtual are virtual for mocking.