Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

148 lines
3.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: API to interface with YouTube via libcurl and OpenSSL
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================
  7. #ifndef YOUTUBEAPI_H
  8. #define YOUTUBEAPI_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "basetypes.h"
  13. class CUtlString;
  14. enum eYouTubeLoginStatus
  15. {
  16. kYouTubeLogin_NotLoggedIn,
  17. kYouTubeLogin_LoggedIn,
  18. kYouTubeLogin_Pending,
  19. kYouTubeLogin_CouldNotConnect,
  20. kYouTubeLogin_Forbidden,
  21. kYouTubeLogin_GenericFailure,
  22. kYouTubeLogin_Cancelled,
  23. };
  24. enum eYouTubeAccessControl
  25. {
  26. kYouTubeAccessControl_Public,
  27. kYouTubeAccessControl_Private,
  28. kYouTubeAccessControl_Unlisted,
  29. };
  30. DECLARE_POINTER_HANDLE(YouTubeUploadHandle_t);
  31. DECLARE_POINTER_HANDLE(YouTubeInfoHandle_t);
  32. /**
  33. * Interface to general response handler for YouTube requests
  34. */
  35. class CYouTubeResponseHandler
  36. {
  37. public:
  38. /**
  39. * Invoked in the main thread after a response has been fully received.
  40. * @param pResponse
  41. */
  42. virtual void HandleResponse( long responseCode, const char *pResponse ) = 0;
  43. };
  44. /**
  45. * Set application specific developer settings, which must be set before trying to log in the user or upload a video
  46. * @param pDeveloperKey
  47. * @param pDeveloperTag
  48. */
  49. void YouTube_SetDeveloperSettings( const char *pDeveloperKey, const char *pDeveloperTag );
  50. /**
  51. * Attempt to log the user in over SSL
  52. * @param pUserName
  53. * @param pPassword
  54. * @param pSource
  55. */
  56. void YouTube_Login( const char *pUserName, const char *pPassword, const char *pSource );
  57. /**
  58. * Cancel the login process.
  59. */
  60. void YouTube_LoginCancel();
  61. /**
  62. * @return eYouTubeLoginStatus
  63. */
  64. eYouTubeLoginStatus YouTube_GetLoginStatus();
  65. /**
  66. * @return YouTube login name
  67. */
  68. const char *YouTube_GetLoginName();
  69. /**
  70. * @return the URL to the YouTube profile, if the user is logged in
  71. */
  72. bool YouTube_GetProfileURL( CUtlString &strProfileURL );
  73. /**
  74. * Attempt to upload a movie file to YouTube
  75. * @param pFilePath full path to the file
  76. * @param pMimeType i.e. "video/mp4"
  77. * @param pTitle (must be less than 60 characters)
  78. * @param pDescription
  79. * @param pCategory - usually "Games" (see category terms in http://gdata.youtube.com/schemas/2007/categories.cat)
  80. * @param pKeywords
  81. * @param access
  82. * @param pURLToVideo if the upload was successful, this string will be a URL to the video on YouTube
  83. * @return true if the video was uploaded successfully, false otherwise
  84. */
  85. YouTubeUploadHandle_t YouTube_Upload( const char* pFilePath, const char *pMimeType, const char *pTitle, const char *pDescription, const char *pCategory, const char *pKeywords, eYouTubeAccessControl access );
  86. /**
  87. * @param handle
  88. * @return true if upload is finished, false otherwise
  89. */
  90. bool YouTube_IsUploadFinished( YouTubeUploadHandle_t handle );
  91. /**
  92. * Get the progress of the upload
  93. * @param handle
  94. * @param flPercentage the parameter to be filled in
  95. * @return true if the upload is still valid, false otherwise
  96. */
  97. bool YouTube_GetUploadProgress( YouTubeUploadHandle_t handle, double &ultotal, double &ulnow );
  98. /**
  99. * @param handle
  100. * @param bSuccess
  101. * @param strURLToVideo
  102. */
  103. bool YouTube_GetUploadResults( YouTubeUploadHandle_t handle, bool &bSuccess, CUtlString &strURLToVideo, CUtlString &strURLToVideoStats );
  104. /**
  105. * Clear status of the upload
  106. * @param handle
  107. */
  108. void YouTube_ClearUploadResults( YouTubeUploadHandle_t handle );
  109. /**
  110. * Cancel the upload of a video
  111. * @param handle
  112. */
  113. void YouTube_CancelUpload( YouTubeUploadHandle_t handle );
  114. /**
  115. * Asynchronously retrieve information for the given video.
  116. * @param pURLToVideoStats
  117. * @param responseHandler
  118. */
  119. YouTubeInfoHandle_t YouTube_GetVideoInfo( const char *pURLToVideoStats, CYouTubeResponseHandler &responseHandler );
  120. /**
  121. * @param handle
  122. */
  123. void YouTube_CancelGetVideoInfo( YouTubeInfoHandle_t handle );
  124. #endif // YOUTUBEAPI_H