Android development of the widevine CDM has been done on the jb-mr2 branch of the cdm code base. This CL contains a merge of that jb-mr2 work to CDM master, and also reflects the evolution of the common Modular DRM code base since jb-mr2 branched. Change-Id: I1d7e1a12d092c00044a4298261146cb97808d4ef
51 lines
1.3 KiB
C++
51 lines
1.3 KiB
C++
// Copyright 2013 Google Inc. All Rights Reserved.
|
|
|
|
#ifndef CDM_TEST_HTTP_SOCKET_H_
|
|
#define CDM_TEST_HTTP_SOCKET_H_
|
|
|
|
#include <string>
|
|
#include "openssl/ssl.h"
|
|
#include "wv_cdm_types.h"
|
|
|
|
namespace wvcdm {
|
|
|
|
// Provides basic Linux based TCP socket interface.
|
|
class HttpSocket {
|
|
public:
|
|
HttpSocket();
|
|
~HttpSocket();
|
|
|
|
void CloseSocket();
|
|
bool Connect(const char* url, const std::string& port, bool enable_timeout,
|
|
bool secure_connection);
|
|
void GetDomainNameAndPathFromUrl(const std::string& url,
|
|
std::string& domain_name,
|
|
std::string& resource_path);
|
|
const std::string& domain_name() const { return domain_name_; };
|
|
const std::string& resource_path() const { return resource_path_; };
|
|
int Read(char* data, int len);
|
|
int Read(char* data, int len, int timeout_in_ms);
|
|
int Write(const char* data, int len);
|
|
|
|
private:
|
|
void CloseSslContext(SSL_CTX* ctx) const {
|
|
if (ctx) SSL_CTX_free(ctx);
|
|
}
|
|
SSL_CTX* InitSslContext(void);
|
|
void ShowServerCertificate(const SSL* ssl);
|
|
|
|
std::string domain_name_;
|
|
bool secure_connect_;
|
|
std::string resource_path_;
|
|
int socket_fd_;
|
|
SSL* ssl_;
|
|
SSL_CTX* ssl_ctx_;
|
|
bool timeout_enabled_;
|
|
|
|
CORE_DISALLOW_COPY_AND_ASSIGN(HttpSocket);
|
|
};
|
|
|
|
}; // namespace wvcdm
|
|
|
|
#endif // CDM_TEST_HTTP_SOCKET_H_
|