~josejuan-sanchez/esajpip/emptypackets

« back to all changes in this revision

Viewing changes to src/jpip/databin_writer.cc

  • Committer: José Juan Sánchez Hernández
  • Date: 2012-07-18 11:40:37 UTC
  • Revision ID: josejuan.sanchez@gmail.com-20120718114037-mslgs1evd0gwjp2y
Modifications to control empty packets

Show diffs side-by-side

added added

removed removed

Lines of Context:
92
92
    return *this;
93
93
  }
94
94
 
 
95
  // PRUEBA
 
96
  // ******
 
97
  DataBinWriter& DataBinWriter::Write2(uint64_t bin_id, uint64_t bin_offset,
 
98
      const File& file, vector<FileSegment> segments, bool last_byte)
 
99
  {
 
100
    char *aux_ptr = ptr;
 
101
 
 
102
    // Calculamos la suma de todos los segmentos del vector
 
103
    uint64_t length = 0;
 
104
    for(int i=0; i < segments.size(); i++)
 
105
    {
 
106
        length = length + segments.at(i).length;
 
107
    }
 
108
 
 
109
    if(WriteHeader(bin_id, bin_offset, length, last_byte))
 
110
    {
 
111
      for(int i=0; i < segments.size(); i++)
 
112
      {
 
113
          if(segments.at(i).length > 0) {
 
114
            file.Seek(segments.at(i).offset);
 
115
            if((ptr + segments.at(i).length) >= end) eof = true;
 
116
            else if(!file.Read(ptr, segments.at(i).length)) eof = true;
 
117
            else ptr += segments.at(i).length;
 
118
          }
 
119
      }
 
120
 
 
121
      if(eof) ptr = aux_ptr;
 
122
      else {
 
123
        prev_databin_class = databin_class;
 
124
        prev_codestream_idx = codestream_idx;
 
125
      }
 
126
    }
 
127
 
 
128
    return *this;
 
129
  }
 
130
  // ******
 
131
 
95
132
  DataBinWriter& DataBinWriter::WritePlaceHolder(uint64_t bin_id, uint64_t bin_offset,
96
133
          const File& file, const PlaceHolder& place_holder, bool last_byte)
97
134
  {