DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs
network_util.cc
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "packager/media/base/network_util.h"
6 
7 namespace edash_packager {
8 namespace media {
9 
10 uint32_t ntohlFromBuffer(const unsigned char* buf) {
11  return (static_cast<uint32_t>(buf[0]) << 24) |
12  (static_cast<uint32_t>(buf[1]) << 16) |
13  (static_cast<uint32_t>(buf[2]) << 8) | (static_cast<uint32_t>(buf[3]));
14 }
15 
16 uint16_t ntohsFromBuffer(const unsigned char* buf) {
17  return (static_cast<uint16_t>(buf[0]) << 8) | (static_cast<uint16_t>(buf[1]));
18 }
19 
20 uint64_t ntohllFromBuffer(const unsigned char* buf) {
21  return (static_cast<uint64_t>(buf[0]) << 56) |
22  (static_cast<uint64_t>(buf[1]) << 48) |
23  (static_cast<uint64_t>(buf[2]) << 40) |
24  (static_cast<uint64_t>(buf[3]) << 32) |
25  (static_cast<uint64_t>(buf[4]) << 24) |
26  (static_cast<uint64_t>(buf[5]) << 16) |
27  (static_cast<uint64_t>(buf[6]) << 8) | (static_cast<uint64_t>(buf[7]));
28 }
29 
30 } // namespace media
31 } // namespace edash_packager
32