Shaka Packager SDK
udp_options.h
1 // Copyright 2016 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 #include <memory>
8 #include <string>
9 
10 #include "packager/base/strings/string_piece.h"
11 
12 namespace shaka {
13 
15 class UdpOptions {
16  public:
17  ~UdpOptions() = default;
18 
22  static std::unique_ptr<UdpOptions> ParseFromString(base::StringPiece udp_url);
23 
24  const std::string& address() const { return address_; }
25  uint16_t port() const { return port_; }
26  bool reuse() const { return reuse_; }
27  const std::string& interface_address() const { return interface_address_; }
28  unsigned timeout_us() const { return timeout_us_; }
29  const std::string& source_address() const { return source_address_; }
30  bool is_source_specific_multicast() const {
31  return is_source_specific_multicast_;
32  }
33  int buffer_size() const { return buffer_size_; }
34 
35  private:
36  UdpOptions() = default;
37 
38  // IP Address.
39  std::string address_ = "0.0.0.0";
40  uint16_t port_ = 0;
41  // Allow or disallow reusing UDP sockets.
42  bool reuse_ = false;
43  // Address of the interface over which to receive UDP multicast streams.
44  std::string interface_address_ = "0.0.0.0";
45  // Timeout in microseconds. 0 to indicate unlimited timeout.
46  unsigned timeout_us_ = 0;
47  // Source specific multicast source address
48  std::string source_address_ = "0.0.0.0";
49  bool is_source_specific_multicast_ = false;
50  // Maximum receive buffer size in bytes.
51  // Note that the actual buffer size is capped by the maximum buffer size set
52  // by the underlying operating system ('sysctl net.core.rmem_max' on Linux
53  // returns the maximum receive memory size).
54  int buffer_size_ = 0;
55 };
56 
57 } // namespace shaka
shaka
All the methods that are virtual are virtual for mocking.
Definition: gflags_hex_bytes.cc:11
shaka::UdpOptions
Options parsed from UDP url string of the form: udp://ip:port[?options].
Definition: udp_options.h:15
shaka::UdpOptions::ParseFromString
static std::unique_ptr< UdpOptions > ParseFromString(base::StringPiece udp_url)
Definition: udp_options.cc:75