buffering_state.cc 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright 2020 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. #include "media/base/buffering_state.h"
  5. #include <string>
  6. #include <vector>
  7. #include "base/check.h"
  8. namespace media {
  9. std::string BufferingStateToString(BufferingState state,
  10. BufferingStateChangeReason reason) {
  11. DCHECK(state == BUFFERING_HAVE_NOTHING || state == BUFFERING_HAVE_ENOUGH);
  12. DCHECK(reason == BUFFERING_CHANGE_REASON_UNKNOWN ||
  13. reason == DEMUXER_UNDERFLOW || reason == DECODER_UNDERFLOW ||
  14. reason == REMOTING_NETWORK_CONGESTION);
  15. std::string state_string = state == BUFFERING_HAVE_NOTHING
  16. ? "BUFFERING_HAVE_NOTHING"
  17. : "BUFFERING_HAVE_ENOUGH";
  18. std::vector<std::string> flag_strings;
  19. if (reason == DEMUXER_UNDERFLOW)
  20. state_string += " (DEMUXER_UNDERFLOW)";
  21. else if (reason == DECODER_UNDERFLOW)
  22. state_string += " (DECODER_UNDERFLOW)";
  23. else if (reason == REMOTING_NETWORK_CONGESTION)
  24. state_string += " (REMOTING_NETWORK_CONGESTION)";
  25. return state_string;
  26. }
  27. } // namespace media