add premiere mode
This commit is contained in:
parent
5af7aae6d3
commit
8b2b9816c9
|
@ -512,6 +512,8 @@ void bind_torrent_handle()
|
|||
.def("piece_priority", _(piece_priority1))
|
||||
.def("prioritize_pieces", &prioritize_pieces)
|
||||
.def("get_piece_priorities", &piece_priorities)
|
||||
.def("is_piece_premiere", _(&torrent_handle::is_piece_premiere))
|
||||
.def("set_piece_premiere", _(&torrent_handle::set_piece_premiere))
|
||||
.def("prioritize_files", &prioritize_files)
|
||||
.def("get_file_priorities", &file_priorities)
|
||||
.def("file_priority", &file_prioritity0)
|
||||
|
|
|
@ -813,6 +813,16 @@ namespace libtorrent {
|
|||
return m_picker->have_piece(index);
|
||||
}
|
||||
|
||||
bool premiere_mode:1;
|
||||
std::unordered_map<piece_index_t, bool> premiere_map;
|
||||
|
||||
void set_piece_premiere(piece_index_t const index, bool prem);
|
||||
|
||||
bool is_piece_premiere(piece_index_t const index)
|
||||
{
|
||||
return premiere_map[index];
|
||||
}
|
||||
|
||||
// returns true if we have downloaded the given piece
|
||||
bool has_piece_passed(piece_index_t index) const
|
||||
{
|
||||
|
|
|
@ -986,6 +986,9 @@ namespace aux {
|
|||
void prioritize_pieces(std::vector<std::pair<piece_index_t, download_priority_t>> const& pieces) const;
|
||||
std::vector<download_priority_t> get_piece_priorities() const;
|
||||
|
||||
void set_piece_premiere(piece_index_t index, bool prem) const;
|
||||
bool is_piece_premiere(piece_index_t index) const;
|
||||
|
||||
#if TORRENT_ABI_VERSION == 1
|
||||
TORRENT_DEPRECATED
|
||||
void prioritize_pieces(std::vector<int> const& pieces) const;
|
||||
|
|
|
@ -1986,7 +1986,7 @@ namespace {
|
|||
TORRENT_ASSERT(t->valid_metadata());
|
||||
|
||||
#ifndef TORRENT_DISABLE_SUPERSEEDING
|
||||
if (t->super_seeding())
|
||||
if (t->is_seed() && (t->super_seeding() || t->premiere_mode))
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log(peer_log_alert::info, "BITFIELD", "not sending bitfield, super seeding");
|
||||
|
@ -2158,6 +2158,7 @@ namespace {
|
|||
// upload-only. If we do, we may be disconnected before we receive the
|
||||
// metadata.
|
||||
if (t->is_upload_only()
|
||||
&& !t->premiere_mode
|
||||
#ifndef TORRENT_DISABLE_SHARE_MODE
|
||||
&& !t->share_mode()
|
||||
#endif
|
||||
|
|
|
@ -635,7 +635,7 @@ namespace libtorrent {
|
|||
}
|
||||
|
||||
#ifndef TORRENT_DISABLE_SUPERSEEDING
|
||||
if (t->super_seeding())
|
||||
if (t->premiere_mode || t->super_seeding())
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log(peer_log_alert::info, "ALLOWED", "skipping allowed set because of super seeding");
|
||||
|
@ -2331,6 +2331,12 @@ namespace libtorrent {
|
|||
, "piece: %d s: %x l: %x", static_cast<int>(r.piece), r.start, r.length);
|
||||
#endif
|
||||
|
||||
if (t->is_piece_premiere(r.piece))
|
||||
{
|
||||
write_reject_request(r);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef TORRENT_DISABLE_SUPERSEEDING
|
||||
if (t->super_seeding()
|
||||
&& !super_seeded_piece(r.piece))
|
||||
|
|
|
@ -2307,6 +2307,24 @@ bool is_downloading_state(int const st)
|
|||
}
|
||||
catch (...) { handle_exception(); }
|
||||
|
||||
void torrent::set_piece_premiere(piece_index_t const index, bool prem)
|
||||
{
|
||||
premiere_map[index] = prem;
|
||||
if (prem == false)
|
||||
{
|
||||
for (auto c : m_connections)
|
||||
{
|
||||
auto p = c->self();
|
||||
p->announce_piece(index);
|
||||
p->send_suggest(index);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
premiere_mode = true;
|
||||
}
|
||||
}
|
||||
|
||||
void torrent::force_recheck()
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
|
|
|
@ -448,6 +448,16 @@ namespace libtorrent {
|
|||
return st;
|
||||
}
|
||||
|
||||
void torrent_handle::set_piece_premiere(piece_index_t const index, bool prem) const
|
||||
{
|
||||
async_call(&torrent::set_piece_premiere, index, prem);
|
||||
}
|
||||
|
||||
bool torrent_handle::is_piece_premiere(piece_index_t const index) const
|
||||
{
|
||||
return sync_call_ret<bool>(false, &torrent::is_piece_premiere, index);
|
||||
}
|
||||
|
||||
void torrent_handle::piece_availability(std::vector<int>& avail) const
|
||||
{
|
||||
auto availr = std::ref(static_cast<aux::vector<int, piece_index_t>&>(avail));
|
||||
|
|
Loading…
Reference in New Issue