1

我尝试在 Linux 上运行 C++ 开发某种 DLNA 媒体服务器。目前,我很难生成所需的 DLNA.ORG_FLAGS 值。我在互联网上找到了以下帮助:

/* DLNA.ORG_FLAGS, padded with 24 trailing 0s
 *     80000000  31  senderPaced
 *     40000000  30  lsopTimeBasedSeekSupported
 *     20000000  29  lsopByteBasedSeekSupported
 *     10000000  28  playcontainerSupported
 *      8000000  27  s0IncreasingSupported
 *      4000000  26  sNIncreasingSupported
 *      2000000  25  rtspPauseSupported
 *      1000000  24  streamingTransferModeSupported
 *       800000  23  interactiveTransferModeSupported
 *       400000  22  backgroundTransferModeSupported
 *       200000  21  connectionStallingSupported
 *       100000  20  dlnaVersion15Supported
 *
 *     Example: (1 << 24) | (1 << 22) | (1 << 21) | (1 << 20)
 *       DLNA.ORG_FLAGS=01700000[000000000000000000000000] // [] show padding
 */
typedef enum {
  DLNA_ORG_FLAG_SENDER_PACED               = (1 << 31),
  DLNA_ORG_FLAG_TIME_BASED_SEEK            = (1 << 30),
  DLNA_ORG_FLAG_BYTE_BASED_SEEK            = (1 << 29),
  DLNA_ORG_FLAG_PLAY_CONTAINER             = (1 << 28),
  DLNA_ORG_FLAG_S0_INCREASE                = (1 << 27),
  DLNA_ORG_FLAG_SN_INCREASE                = (1 << 26),
  DLNA_ORG_FLAG_RTSP_PAUSE                 = (1 << 25),
  DLNA_ORG_FLAG_STREAMING_TRANSFER_MODE    = (1 << 24),
  DLNA_ORG_FLAG_INTERACTIVE_TRANSFERT_MODE = (1 << 23),
  DLNA_ORG_FLAG_BACKGROUND_TRANSFERT_MODE  = (1 << 22),
  DLNA_ORG_FLAG_CONNECTION_STALL           = (1 << 21),
  DLNA_ORG_FLAG_DLNA_V15                   = (1 << 20),
} dlna_org_flags_t;

但现在我不知道如何获取包含所需“DLNA.ORG_FLAGS=xxxx”的字符串。所以我的问题是如何从这些值中获取所需的字符串?

4

2 回答 2

1

以防万一有人遇到同样的麻烦。这是我想出的解决方案:

typedef enum 
{
  DLNA_ORG_FLAG_SENDER_PACED               = (1 << 31),
  DLNA_ORG_FLAG_TIME_BASED_SEEK            = (1 << 30),
  DLNA_ORG_FLAG_BYTE_BASED_SEEK            = (1 << 29),
  DLNA_ORG_FLAG_PLAY_CONTAINER             = (1 << 28),
  DLNA_ORG_FLAG_S0_INCREASE                = (1 << 27),
  DLNA_ORG_FLAG_SN_INCREASE                = (1 << 26),
  DLNA_ORG_FLAG_RTSP_PAUSE                 = (1 << 25),
  DLNA_ORG_FLAG_STREAMING_TRANSFER_MODE    = (1 << 24),
  DLNA_ORG_FLAG_INTERACTIVE_TRANSFERT_MODE = (1 << 23),
  DLNA_ORG_FLAG_BACKGROUND_TRANSFERT_MODE  = (1 << 22),
  DLNA_ORG_FLAG_CONNECTION_STALL           = (1 << 21),
  DLNA_ORG_FLAG_DLNA_V15                   = (1 << 20)
} dlna_org_flags;

std::string dlnaFlags = "";
char dlna_info[448];

sprintf(dlna_info, "%s=%.8x%.24x", "DLNA.ORG_FLAGS", DLNA_ORG_FLAG_TIME_BASED_SEEK | DLNA_ORG_FLAG_BYTE_BASED_SEEK | DLNA_ORG_FLAG_STREAMING_TRANSFER_MODE), 0);
dlnaFlags = std::string(dlna_info);

现在如本例所示,此代码使字符串“dlnaFlags”包含所需的字符串“DLNA.ORG_FLAGS=xxxx”。以基于时间的寻道、基于字节的寻道和流传输模式为例。

于 2015-06-12T16:28:55.210 回答
1

无需发明轮子。如果您对许可没有问题,可以检查 gupnp。关于 DLNA 标志,他们有这样的:http: //sourcecodebrowser.com/gupnp-av/0.6.0/gupnp-dlna_8h.html#a1c454f2ab71f6a5f53ba955850917370

于 2015-06-30T11:28:40.710 回答